![](/img/trans.png)
[英]node.js/express.js connection pool Cannot read properties of undefined (reading 'getConnection')
[英]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 和 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.