1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Azure Functionsの出力バインディングにCosmosDBを設定した後にfunction.jsを編集しないと「'CosmosDB' does not exist」と言われる

Posted at

事象

Azure Functionsの統合の出力から出力先にCosmosDB追加した場合、context.bindings.outputDocument を使ってCosmosDBに挿入することができる。
image.png

コードサンプル

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.

対策

function.jsonを編集する
image.png

編集例

collectionName -> containerName
connectionStringSetting -> connection
にする

{
  "name": "outputDocument2",
  "direction": "out",
  "type": "cosmosDB",
  "methods": [],
  "databaseName": "outDatabase",
-  "collectionName": "MyCollection",
+  "containerName": "MyCollection",
-  "connectionStringSetting": "CosmosDbConnectionSetting"
+  "connection": "CosmosDbConnectionSetting",
}

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?