Azure / Azure/Azure-Functions

HTTP triggered function with Cosmos DB output Binding in-process mode

Open
#2,408 6 comments 3 reactions 0 assignees View on GitHub
v4-bug
Dominant language
PowerShell
Stars
1.1k
Forks
215
Avg merge
4h 2m
Merged PRs (30d)
1

Description

Function App name: afreen-funcapp-001
Tools used: Azure Portal
New V4 app or existing V3 app migrated to V4: V4

While trying to integrate cosmos DB output binding in HTTP triggered function using **Integration** tab, v2.x+ binding parameters are getting generated for v4 function. Hence its throwing 500 error **`(Cosmos DB connection configuration 'CosmosDB' does not exist. Make sure that it is a defined App Setting)`** initially. After correcting [ConnectionStringSetting](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2-output?tabs=python-v2%2Cin-process%2Cnodejs-v4%2Cfunctionsv2&pivots=programming-language-csharp#attributes) to [connection](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2-output?tabs=python-v2%2Cin-process%2Cnodejs-v4%2Cextensionv4&pivots=programming-language-csharp#attributes), later its throwing **`Value cannot be null. (Parameter 'databaseId')`** error for incorrect attribute **collectionName** and getting expected result post replacing **collectionName** to **containerName** for v4.

image

**Auto generated binding with error-**
```
{
"bindings": [
{
"authLevel": "function",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"methods": [
"get",
"post"
]
},
{
"name": "$return",
"type": "http",
"direction": "out"
},
{
"name": "outputDocument",
"direction": "out",
"type": "cosmosDB",
"connectionStringSetting": "afreen-cosmosdb_DOCUMENTDB",
"databaseName": "outDatabase",
"collectionName": "MyCollection",
"createIfNotExists": true,
"partitionKey": "/id"
}
]
}
```

**After Correction-**

Below Bindings are working as expected.

```
{
"bindings": [
{
"authLevel": "function",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"methods": [
"get",
"post"
]
},
{
"name": "$return",
"type": "http",
"direction": "out"
},
{
"name": "outputDocument",
"direction": "out",
"type": "cosmosDB",
"connection": "afreen-cosmosdb_DOCUMENTDB",
"databaseName": "outDatabase",
"containerName": "MyCollection",
"createIfNotExists": true,
"partitionKey": "/id"
}
]
}
```

image

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.