簡體   English   中英

Azure updateEntity - 無法讀取未定義的屬性(讀取“替換”)[Node.js]

[英]Azure updateEntity - Cannot read properties of undefined (reading 'replace') [Node.js]

我正在使用@azure/data-tables ,我的目標是更新表格。 我按照文檔中的建議使用updateEntity ( https://docs.microsoft.com/en-us/javascript/api/@azure/data-tables/tableclient?view=azure-node-latest#@azure-data-tables -tableclient-updateentity )。 不幸的是,我經常遇到異常:“Azure updateEntity - 無法讀取未定義的屬性(讀取'替換')”。 我肯定提供了正確的帳戶和帳戶密鑰。 有趣的是,createEntity 工作得很好——我可以看到一個條目添加到我的表中。

index.js 中的代碼:

 const { TableClient, AzureNamedKeyCredential } = require("@azure/data-tables"); module.exports = async function (context, req) { const account = "" const accountKey = "" const tableName = "Person" const sharedKeyCredential = new AzureNamedKeyCredential(account, accountKey); const client = new TableClient( `https://${account}.table.core.windows.net`, `${tableName}`, sharedKeyCredential ); const entity = { PartitionKey: "1", RowKey: "1", Name: 'Mathilde' }; await client.updateEntity(entity); }

我試過了:

  • 添加現有的 PartitionKey/RowKey 和唯一的 PartitionKey/RowKey
  • 試圖更新到不同的表
  • 將 RowKey 轉為數字
  • 調試並檢查是否有任何未定義的內容(不,顯然一切都很好 - 對於實體​​和客戶端)
  • 檢查其他方法是否有效(是的,createEntity 有效)

我正在處理的表目前包含三個屬性(PartitionKey、RowKey 和 Name),並且都設置為字符串。

如果您想查看它,這是我的 function.json:

 { "bindings": [ { "authLevel": "function", "type": "httpTrigger", "direction": "in", "name": "input", "methods": ["put"], "route": "updatingUsers" }, { "type": "http", "direction": "out", "name": "res" } ], "disabled": false }

如果您能幫助我解決這個問題,我將不勝感激!

我發現出了什么問題。 顯然,如果您的屬性的名稱以大寫開頭,那么您也必須使用大寫,但是即使 PartitionKey 和 RowKey 在表中都是大寫的,它們在代碼中也必須小寫。 很奇怪,但它解決了所有錯誤。 案件已結案:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM