Unable to resolve the value for property 'CosmosDBAttribute.ConnectionStringSetting'

Viewed 6093

I have developed simple Service Bus Trigger with CosmosDB Output with Visual Studio. Connection strings of Service Bus and CosmosDB are defined in local.settings.json. Code is fully function locally. Now I have Zip Published Function(C#) to Azure.

I'm getting Error:

Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1'. 
Microsoft.Azure.WebJobs.Host: Unable to resolve the value for property 
'CosmosDBAttribute.ConnectionStringSetting'. 

What should I do?

enter image description here

3 Answers

The error tells you need to add the settings on Azure.

azure function on azure is different from azure functions on local. on local the settings is in the local.settings.json. But on azure it is in the Configuration.(Even if you deploy the local.settings.json, the function will read env settings from Congfiguration)

enter image description here

enter image description here

And dont forget to save your edit.

I had the same issue in local when running the azure function. My connection string was not accepted because the AccountKey was considered part of the URL of AccountEndpoint, and I gave space between the endpoint of AccountKey and AccountEndpoint.

"connectionStringSetting": "AccountEndpoint=; AccountKey=;"

{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "myCosmosDb": "AccountEndpoint=https://mycosmoscosmosdb.documents.azure.com:443/; AccountKey=asd4ph1omRg9Rn4dlj7h1f7XqUdO1mHJcpG9rN1XECSO4P6LKorDXjdqK8VTookKvbKXjPTulpEsdfdsbwg==;"
  }
}
Related