2017-06-28 22 views

回答

0

請通過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 
} 
+0

鏈路不與方法提供查詢/更新/使用的node.js天青功能綁定在天青-表中刪除的實體。你能提供一個代碼片段嗎?此外鏈接https://stackoverflow.com/questions/42492777/how-to-update-a-azure-table-row-in-azure-function-using-bindings地址相同的問題。有沒有解決這個問題的方法。 – sameeksha

+0

replaceEntity等的標準azure-table方法顯示錯誤 – sameeksha

+0

@sameeksha如果您需要任意查詢/刪除等,您將不得不手動執行此操作,而無需直接從函數綁定中獲得幫助。我無法給你一個沒有被你指定的任務的片段。 – Mikhail

相關問題