2017-06-28 11 views
0

Azure node.js関数を更新して、空白テーブルストレージ内のエンティティを更新/取得します。関数内で見つかった方法は、エントリを挿入する方法だけです。 テーブルはどのようにクエリ/更新できますか?Azure node.jsは、空白テーブルストレージ内のエンティティを更新/取得する機能を提供します。

このタスクは、行キーとパーティションキーに基づいてデータを検索し、{"num":val}として格納されているキー値ペアの値を増やすことです。

答えて

0

Azure Functions Storage table bindingsの「ストレージテーブル入力バインド」を読んでください。これにはfunction.jsonとNode関数の例があります。

何かがまだ明らかでない場合は、正確な問題を解決してください。

UPDATE:ここ

は、あなたの洗練された問題のための試料溶液です。私は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メソッドshow error – sameeksha

+0

@sameeksha任意のクエリ/削除などが必要な場合は、関数バインディングの直接の助けを借りて手動で行う必要があります。私はあなたに指定されていないタスクのスニペットを与えることはできません。 – Mikhail

関連する問題