亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Azure HTTP 函數無法發布

Azure HTTP 函數無法發布

C#
慕慕森 2023-12-17 10:23:08
我正在嘗試將我的 Azure HTTP 函數從 Visual Studio Code 發布到我們的 Azure 平臺。該代碼在本地運行該函數時工作正常并成功發布,但在發布時拋出以下錯誤。我嘗試使用 DocumentDB 而不是 CosmosDB,但缺乏將數據插入 CosmosDB 所需的插入功能。 Stackoverflow 沒有針對此類特定問題的解決方案。功能碼//write to cosmosdb[FunctionName("InsertItem")] public static HttpResponseMessage Run(     [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)]HttpRequestMessage req,     [CosmosDB(         databaseName: "ToDoList",         collectionName: "RFIDContainer",         ConnectionStringSetting = "myCosmosDBConnection")]     out RFIDBaseTag document,     ILogger log) {     string hexData = "";    string afi = "";    string eid = "";    string dsfid = "";    //Guid DeviceID = new Guid();    //Guid AppID = new Guid();    var content = req.Content;     string jsonContent = content.ReadAsStringAsync().Result;     dynamic json = JsonConvert.DeserializeObject<MyClass>(jsonContent);    hexData = json?.hexData;    afi = json?.afi;    eid = json?.eid;    dsfid = json?.dsfid;    /*Guid devGuid;    Guid.TryParse(json.AppID.ToString(), out devGuid);    DeviceID = devGuid;    Guid appGuid;    Guid.TryParse(json.AppID.ToString(), out appGuid);    AppID = appGuid;*/    byte[] hexToByte = AzureRFIDTagReader.StringToByteArray(hexData);    RawRFIDReading raw = new RawRFIDReading();    raw.afi = afi;    raw.eid = eid;    raw.dsfid = dsfid;    raw.RawData = hexToByte;    RFIDBaseTag rtag = RFIDTagFactory.GetTag(raw);    string serializedtag = JsonConvert.SerializeObject(rtag);    //document = JsonConvert.DeserializeObject<MyClass>(jsonContent);    //document = JsonConvert.DeserializeObject<RFIDBaseTag(serializedtag);    document = rtag;    log.LogInformation($"C# Queue trigger function inserted one row");    return new HttpResponseMessage(HttpStatusCode.Created); }錯誤信息:函數(xxx/InsertItem)錯誤:Microsoft.Azure.WebJobs.Host:索引方法“InsertItem”錯誤。 Microsoft.Azure.WebJobs.Host:無法解析屬性“CosmosDBAttribute.ConnectionStringSetting”的值。確保該設置存在并且具有有效值。我可以在本地發布該函數,但不能在 Azure 上發布。有什么建議么?
查看完整描述

1 回答

?
米琪卡哇伊

TA貢獻1998條經驗 獲得超6個贊

當您發布函數時,您的local.settings.json文件不會發布。

您需要將這些設置添加為 Azure Functions 應用程序設置的一部分。在您的情況下,您需要在其中添加 myCosmosDBConnection 值。



查看完整回答
反對 回復 2023-12-17
  • 1 回答
  • 0 關注
  • 136 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號