Azure / Azure/azure-functions-host
Azure Cosmos DB Input bindings come with incorrect fields on Azure Portal
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
When you create an Azure Cosmos DB Input in your function on Azure Portal, the template generates a binding with incorrect fields like `connectionStringSetting` and `collectionName` which should be `connection` and `containerName`.
#### Investigative information
- Timestamp: 2023-09-24T13:38:46.408
- Function App version: 4.26.1.21286
- Function App name: week3-coursera
- Function name(s) (as appropriate): HttpTrigger1
- Invocation ID: e64eb6c0-1575-41a6-a145-5042ba4db216
- Region: Germany West Central
#### Repro steps
Provide the steps required to reproduce the problem:
1. Sign in to Azure Portal
2. Create an Azure Cosmos DB Account
3. Create a new Azure Cosmos DB Container
4. Create a Function App
7. Create an HTTP Trigger Function
8. Navigate to Integrations tab in your function
9. Add a CosmosDB Input
10. Open file logs
11. Try to get data from CosmosDB using the function
12. Observe the error log that says: `Cosmos DB connection configuration 'CosmosDB' does not exist. Make sure that it is a defined App Setting.`
Or you can simply follow this guide on Microsoft Learn as newly created CosmosDB bindings are faulty right now:
https://learn.microsoft.com/en-us/training/modules/chain-azure-functions-data-using-bindings/5-read-data-with-input-bindings-portal-lab?pivots=javascript
#### Expected behavior
The function should be able to connect to Azure Cosmos DB.
#### Actual behavior
The function does not connect to Azure Cosmos DB and throws the following error:
`Cosmos DB connection configuration 'CosmosDB' does not exist. Make sure that it is a defined App Setting.`
#### Known workarounds
You can manually change the field names in bindings as below:
- Change `connectionStringSetting` to `connection`
- Change `collectionName` to `containerName`
#### Related information
Provide any related information
* Programming language used
Javascript
* Links to source
https://learn.microsoft.com/en-us/training/modules/chain-azure-functions-data-using-bindings/5-read-data-with-input-bindings-portal-lab?pivots=javascript
* Bindings used
Azure CosmosDB Input
Source
Bindings
```json
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"name": "documentUrls",
"direction": "in",
"type": "cosmosDB",
"connectionStringSetting": "####_DOCUMENTDB",
"databaseName": "new-database",
"collectionName": "new-container",
"id": "{id}",
"partitionKey": "/id"
}
]
}
```
Code
```javascript
module.exports = function (context, req) {
var bookmark = context.bindings.bookmark
if(bookmark){
context.res = {
body: { "url": bookmark.url },
headers: {
'Content-Type': 'application/json'
}
};
}
else {
context.res = {
status: 404,
body : "No bookmarks found",
headers: {
'Content-Type': 'application/json'
}
};
}
context.done();
};
```
Contributor guide
Assessment
This issue has not been assessed yet.