2017-08-12 8 views
2

をSDK:Azureの機能は、任意のコードを変更せず1.0.1 CLIツールにアップグレードした後、私は突然、次のエラーを取得するために始めた

ResizeImage: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ResizeImage'. 
Microsoft.Azure.WebJobs.Extensions.DocumentDB: 
'Id' is required when binding to a DocumentClient property. 

次のコード:

[FunctionName(nameof(ResizeImage))] 
public static async Task RunAsync([BlobTrigger("profile-pictures/{name}")] CloudBlockBlob myBlob, string name, [DocumentDB(databaseName: "x", collectionName: "UserProfile", CreateIfNotExists = true)] DocumentClient client, [Blob("profile-pictures/resized-{name}", FileAccess.ReadWrite)] CloudBlockBlob resizedBlob, TraceWriter log) 

を私はIdがあると思いましたオプション?少なくともそれはドキュメントが言うことです。ドキュメントによると

The properties id and sqlQuery cannot both be specified. If neither id nor sqlQuery is set, the entire collection is retrieved.

生成されたJSON:

{ 
    "bindings": [ 
    { 
     "type": "blobTrigger", 
     "path": "profile-pictures/{name}", 
     "direction": "in", 
     "name": "myBlob" 
    }, 
    { 
     "type": "documentDB", 
     "databaseName": "x", 
     "collectionName": "UserProfile", 
     "createIfNotExists": true, 
     "direction": "out", 
     "name": "client" 
    }, 
    { 
     "type": "blob", 
     "path": "profile-pictures/resized-{name}", 
     "direction": "inout", 
     "name": "resizedBlob" 
    } 
    ], 
    "disabled": false, 
    "scriptFile": "..\\X.Functions.dll", 
    "entryPoint": "X.Functions.ResizeImage.RunAsync" 
} 

私が使用している1.0.0 SDK

答えて

0

I thought Id is optional? At least that's what the docs says.

はい、IDはオプションです。しかし、Azure Functions Cosmos DB bindingsの文書によれば。バインディングタイプとしてIEnumerable < dynamic>を使用する必要があります。以下のようにコードを変更してください。

[DocumentDB(...)] IEnumerable<dynamic> documents 

すべてのドキュメントをコレクションから取得します。私はそれをテストし、それは私の側で正常に働いた。

また、DocumentDBからデータを取得する場合は、方向をinに変更する必要があります。

"direction": "in" 
+0

ご回答のおかげで、私は私が私の機能の属性および型定義に依存するため、その場でそれを生成するためのSDKを使用していますように私はちょうど生成されたJSONを変更することはできません。 –

+0

バインドタイプをIEnumerable に変更しましたか?これで問題は解決しますか? – Amor

+0

はい、そうではありませんでした。これは明らかに既知のバグであり、将来修正される予定です。 –

関連する問題