2017-05-12 11 views
2

私はAzureポータルで作成したAzure関数を持っており、VS2017プレビューに関連付けられているビジュアルスタジオの空白ツールを使用して再作成します。DocumentDB入力をAzure関数にバインドする方法は?

私の関数はTimerであり、Azure DocumentDBの入力バインディング(クエリ付き)とAzure Service Busキューへの出力バインディングもあります。

ここではポータルからfunctions.json定義です:

ローカルで実行
public static void Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, TraceWriter log, ICollector<dynamic> outputQueue, IEnumerable<dynamic> incomingDocuments) 
{ 
    log.Info($"C# Timer trigger function executed at: {DateTime.Now}"); 

    //Inspect incomingDocuments .. push messages to outputQueue 
} 

、タイマー:VS2017で

{ 
    "bindings": [ 
    { 
     "name": "myTimer", 
     "type": "timerTrigger", 
     "direction": "in", 
     "schedule": "0 */5 * * * *" 
    }, 
    { 
     "type": "serviceBus", 
     "name": "outputQueue", 
     "queueName": "test-output-requests", 
     "connection": "send-refresh-request", 
     "accessRights_": "Send", 
     "direction": "out" 
    }, 
    { 
     "type": "documentDB", 
     "name": "incomingDocuments", 
     "databaseName": "test-db-dev", 
     "collectionName": "TestingCollection", 
     "sqlQuery": "select * from c where c.docType = \"Test\"", 
     "connection": "my-testing_DOCUMENTDB", 
     "direction": "in" 
    } 
    ], 
    "disabled": false 
} 

私はAzureの機能プロジェクト、TimerTriggeredテンプレートを使用して、その後Azureの機能を作成し、期待どおりに起動されますが、コード内の入出力バインディングを再作成するにはどうすればよいですか?私は、どの属性を使うべきか、また、json設定ファイルで必要なものを配線するために必要なものがわからない。

答えて

4
  1. [DocumentDB(ConnectionStringSetting = "")]IEnumerable<dynamic> incomingDocuments 
    
  2. (ならびに他のプロパティを追加する)を以下のようにusing Microsoft.Azure.WebJobs

  3. 更新documentDbパラメータを追加し、以下のnuget可能パッケージに https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.DocumentDB/

  4. の参照を追加し更新serviceBusパラメータ次のように

    [ServiceBus("test-output-requests",Connection = "ConnectionValue")] 
    

bin/functionName/function.json

おかげで、
Naren

正しい方向に私を指摘している
+1

おかげで生成されたfunction.jsonを確認してください。 2つの追加情報: [Microsoft.Azure.WebJobs.Extensions.DocumentDB]のv1.1.0-beta1を参照する必要がありました(https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.DocumentDB /)pkg。 'ServiceBus'属性のバインディングに' function.json'の定義が正しくないシリアル化バグがあり、そのNuGet pkgへの更新を待っています.GitHub [issue](https://github.com/Azure/azure)を参照してください。 -functions-vs-build-sdk/issues/40) –

+0

さらにpkgのアップデートは、[available](https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions/1.0.0-alpha4)でServiceBusの問題の修正。 –

関連する問題