0
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?

More than 3 years have passed since last update.

AzureFunctionsでCosmosDBの入力バインディングでInternal500エラー解消

Last updated at Posted at 2020-06-22

CosmosDBのデータを入力バインディングで取得して表示するAzureFunctionをjsでしようとしたらInternal500エラーでつまづいたの解決メモ

###Error内容

Can't bind CosmosDB to type 'System.String'.
 Possible causes:
 1) Tried binding to 'Microsoft.Azure.Documents.Client.DocumentClient, Microsoft.Azure.DocumentDB.Core, Version=2.9.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' but user type assembly was 'System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e.

###functioin.jsonから下記を削除で解決らしい

"id": "",
"sqlQuery": ""

NoName_2020-6-22_19-16-26_No-00.png

削除して保存しても、上書きできなかったです。。

###旧UIで構築して新UIで実行

関数のトップの概要から旧UIに切り替えして入力バインディングを設定

NoName_2020-6-22_19-47-27_No-00.png

これで一覧取得の動作確認できました。。

module.exports = async function (context, req) {
    // 一覧
    context.res = {
        status: 200,
        body: context.bindings.inputDocument.filter(elm => !elm.isDeleted).map(elm => {
            return {
                id: elm.id,
                title: elm.title,
                content: elm.content
            };
        })
    };
};

NoName_2020-6-22_19-53-29_No-00.png

###参考サイト
Azure Cosmos DB input binding for an Azure Function doesn't work
https://stackoverflow.com/questions/61988060/azure-cosmos-db-input-binding-for-an-azure-function-doesnt-work
Azure learning error: Can't bind CosmosDB to type 'System.String'
https://docs.microsoft.com/en-us/answers/questions/31217/azure-learning-error-cant-bind-cosmosdb-to-type-sy.html

0
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
0
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?