事象
Azure Functionsの統合の出力から出力先にCosmosDB追加した場合、context.bindings.outputDocument
を使ってCosmosDBに挿入することができる。
コードサンプル
module.exports = async function (context, myBlob) {
context.log("JavaScript blob trigger function processed blob \n Blob:", context.bindingData.blobTrigger, "\n Blob Size:", myBlob.length, "Bytes");
const output = { "userId": 2, "message": "test" }
context.bindings.outputDocument = JSON.stringify(output);
};
が、このまま実行し「呼び出し」タブを見ると'CosmosDB' does not exist
といわれる。
Cosmos DB connection configuration 'CosmosDB' does not exist. Make sure that it is a defined App Setting.
対策
編集例
collectionName -> containerName
connectionStringSetting -> connection
にする
{
"name": "outputDocument2",
"direction": "out",
"type": "cosmosDB",
"methods": [],
"databaseName": "outDatabase",
- "collectionName": "MyCollection",
+ "containerName": "MyCollection",
- "connectionStringSetting": "CosmosDbConnectionSetting"
+ "connection": "CosmosDbConnectionSetting",
}
参考