2017-07-21 7 views
1

自分の進捗状況で編集しました。バイナリAzure関数を使用したDocumentDb

私はAzure関数内でDocumentDbを使用しようとしていますが、私がdllをビルドして展開できる新しいVisual Studio Toolingで書いています。私のfunction.jsonファイルはツールによって作成されるので、function.jsonでバインディングを作成することはできません。属性を使用する必要があります。

私は自分のソリューションにMicrosoft.Azure.Webjobs.Extensions.DocumentDBパッケージを追加しました。私は、関数のシグネチャいる:ツールによってコンパイルfunction.jsonがある

await docdbcli.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri("customerdocumentversionsdb", "snapshots"), new 
     { 
      id = "edse", 
      customer = "expedia", 
      document = Converter.Serialize(jliff), 
      version = "sourceedited" 
     }); 

::私が持っているメソッド本体で

public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] 

HttpRequestMessage req, 
[DocumentDB("database", "collection"ConnectionStringSetting = "conn", Id = "w", PartitionKey = "customer")) DocumentClient docdbcli, 
TraceWriter log) 

{ 
"bindings": [ 
{ 
    "type": "httpTrigger", 
    "methods": [ 
    "get", 
    "post" 
    ], 
    "authLevel": "function", 
    "direction": "in", 
    "name": "req" 
}, 
{ 
    "type": "documentDB", 
    "databaseName": "customerdocumentversionsdb", 
    "collectionName": "snapshots", 
    "createIfNotExists": false, 
    "connection": "conn", 
    "id": "w", 
    "partitionKey": "customer", 
    "direction": "out", 
    "name": "docdbcli" 
}, 
{ 
    "name": "$return", 
    "type": "http", 
    "direction": "out" 
} 
], 
"disabled": false, 
"scriptFile": "..\\MtWithRulesFunctionApp.dll", 
"entryPoint": "MtWithRulesFunctionApp.PreEditSource.Run" 
} 

マイドキュメントが書き込まれていませんおそらくバインディングは約のために指定されているからです。

+0

一般的に、あなたはかなり異なるものに質問を編集すべきではありません... – Mikhail

答えて

3

あなたは、Microsoft.Azure.WebJobs.Extensions.DocumentDB NuGetパッケージを参照する名前空間

using Microsoft.Azure.WebJobs.Extensions.DocumentDB; 

を使用して、DocumentDB属性を使用して関数パラメータを飾るする必要があります。

+0

私はあなたの答えを投稿していたので、感謝しました。しかし、私の文書はデータベースに書き込まれていないので、docdbcliはnullです。 – user1200984

0

ライブラリのv1.5で問題が発生しました。 1.4の作品を使用しています。

関連する問題