0
如何更新Azure node.js函數以更新/檢索天藍色表存儲中的實體。我在函數中發現的唯一方法是插入一個條目。 那麼如何查詢/更新表格呢?Azure node.js用於更新/檢索天藍色表存儲中的實體
任務是簡化基於rowkey和分區鍵檢索數據,然後遞增存儲爲{"num":val}
的鍵值對的值。
如何更新Azure node.js函數以更新/檢索天藍色表存儲中的實體。我在函數中發現的唯一方法是插入一個條目。 那麼如何查詢/更新表格呢?Azure node.js用於更新/檢索天藍色表存儲中的實體
任務是簡化基於rowkey和分區鍵檢索數據,然後遞增存儲爲{"num":val}
的鍵值對的值。
請通過Azure Functions Storage table bindings的「存儲表輸入綁定」進行閱讀。它有function.json
和Node功能的例子。
如果仍有問題仍未解決,請完善問題。
更新:
這裏是一個爲您的精緻問題的示例解決方案。我只有在C#中,我希望你可以派生節點實現。
csx
#r "Microsoft.WindowsAzure.Storage"
using System;
using System.Net;
using Microsoft.WindowsAzure.Storage.Table;
public class Entity : TableEntity
{
public int num {get; set;}
}
public static HttpResponseMessage Run(HttpRequestMessage req, string partition,
string rowkey, Entity inputEntity, out Entity outputEntity)
{
if (inputEntity == null)
outputEntity = new Entity { PartitionKey = partition, RowKey = rowkey, num = 1};
else
{
inputEntity.num += 1;
outputEntity = inputEntity;
}
return req.CreateResponse(HttpStatusCode.OK, $"Done, num = {outputEntity.num}");
}
function.json
:
{
"bindings": [
{
"authLevel": "function",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"route": "HttpTriggerTableUpdate/{partition}/{rowkey}"
},
{
"name": "$return",
"type": "http",
"direction": "out"
},
{
"type": "table",
"name": "inputEntity",
"tableName": "MyTable",
"partitionKey": "{partition}",
"rowKey": "{rowkey}",
"connection": "my_STORAGE",
"direction": "in"
},
{
"type": "table",
"name": "outputEntity",
"tableName": "MyTable",
"partitionKey": "{partition}",
"rowKey": "{rowkey}",
"connection": "my_STORAGE",
"direction": "out"
}
],
"disabled": false
}
鏈路不與方法提供查詢/更新/使用的node.js天青功能綁定在天青-表中刪除的實體。你能提供一個代碼片段嗎?此外鏈接https://stackoverflow.com/questions/42492777/how-to-update-a-azure-table-row-in-azure-function-using-bindings地址相同的問題。有沒有解決這個問題的方法。 – sameeksha
replaceEntity等的標準azure-table方法顯示錯誤 – sameeksha
@sameeksha如果您需要任意查詢/刪除等,您將不得不手動執行此操作,而無需直接從函數綁定中獲得幫助。我無法給你一個沒有被你指定的任務的片段。 – Mikhail