Cosmos DB Trigger Can't Find App Setting for Connection String .net6
See original GitHub issueCosmos DB trigger failing to retrieve app setting in Azure. When running locally with an environment variable set on the machine this works fine. When publishing to Azure this
.net6 RC2 Azure Functions v4
Repro steps
Provide the steps required to reproduce the problem
- Create CosmosDbTrigger function
- Publish to Azure Functions App, wait for error.
Expected behavior
Trigger should pick up connection string from App Settings and function should be indexed.
Actual behavior
Trigger fails, stating app setting does not exist. Function fails to load
Related information
Error message from Azure logs:
2021-10-17T21:03:29.094 [Error] Error indexing method 'SendJobsUpdatedNotification'Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException : Error indexing method 'SendJobsUpdatedNotification' ---> System.InvalidOperationException : Cannot create container information for JobProgress in database Zeus with lease Leases_JobProgress in database Zeus : Cosmos DB connection configuration 'CosmosDBConnection' does not exist. Make sure that it is a defined App Setting. ---> System.InvalidOperationException : Cosmos DB connection configuration 'CosmosDBConnection' does not exist. Make sure th
at it is a defined App Setting.at Microsoft.Azure.WebJobs.Extensions.CosmosDB.DefaultCosmosDBServiceFactory.ResolveConnectionInformation(String connection) at C:\azure-webjobs-sdk-extensions\src\WebJobs.Extensions.CosmosDB\Config\DefaultCosmosDBServiceFactory.cs : 45
at Microsoft.Azure.WebJobs.Extensions.CosmosDB.DefaultCosmosDBServiceFactory.CreateService(String connectionName,CosmosClientOptions) at C:\azure-webjobs-sdk-extensions\src\WebJobs.Extensions.CosmosDB\Config\DefaultCosmosDBServiceFactory.cs : 27
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key,Func`2)
at Microsoft.Azure.WebJobs.Extensions.CosmosDB.CosmosDBExtensionConfigProvider.GetService(String connection,String) at C:\azure-webjobs-sdk-extensions\src\WebJobs.Extensions.CosmosDB\Config\CosmosDBExtensionConfigProvider.cs : 108
at async Microsoft.Azure.WebJobs.Extensions.CosmosDB.CosmosDBTriggerAttributeBindingProvider`1.TryCreateAsync[T](TriggerBindingProviderContext context) at C:\azure-webjobs-sdk-extensions\src\WebJobs.Extensions.CosmosDB\Trigger\CosmosDBTriggerAttributeBindingProvider.cs : 81End of inner exception
at async Microsoft.Azure.WebJobs.Extensions.CosmosDB.CosmosDBTriggerAttributeBindingProvider`1.TryCreateAsync[T](TriggerBindingProviderContext context) at C:\azure-webjobs-sdk-extensions\src\WebJobs.Extensions.CosmosDB\Trigger\CosmosDBTriggerAttributeBindingProvider.cs : 107
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Triggers.CompositeTriggerBindingProvider.TryCreateAsync(TriggerBindingProviderContext context) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Triggers\CompositeTriggerBindingProvider.cs : 22
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexMethodAsyncCore(MethodInfo method,IFunctionIndexCollector) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs : 172
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexMethodAsync(MethodInfo method,IFunctionIndexCollector) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs : 149End of inner exception
at async Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexMethodAsync(MethodInfo method,IFunctionIndexCollector) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs : 157
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexTypeAsync(Type type,IFunctionIndexCollector) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs : 85
Microsoft.Azure.WebJobs 3.0.30 Microsoft.Azure.WebJobs.Extensions 4.0.1 Microsoft.Azure.WebJobs.Extensions.CosmosDB 4.0.0-preview2
Screenshot of App Setting
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Set Cosmos DB Binding Connection String At Runtime
I am using Cosmos Db trigger azure function ,i want to get the ConnectionStringSetting value from key vault ,so i added below code...
Read more >Allow CosmosDbTrigger connection to be specified in ...
But then I come to add a CosmosDbTrigger and I cannot re-use that app settings value I have with the connection string. I...
Read more >Cannot read connection string defined in local.settings.json
I use Visual Studio 2019 to develop HTTP triggered Azure Functions (v3) locally. I defined a Startup class that initializes and injects a ......
Read more >Set Cosmos DB Trigger Connection String At Runtime
In the code above, ConnectionStringSetting is the name of the setting that contains the connection string. In this case, it is ...
Read more >Exploring .NET - Azure Cosmos DB + Functions App [E3]
Ok keep that Azure tab open and go back to Visual Studio. We can store this connection string in a settings file called...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you sir!
This is part of the preview3 release