I'm using .NET 6 and Azure functions v4. I would like to use Keyvault and App configuration (for non secure configuration) for bind variables in CosmosDbTrigger but have been unsuccessful.
For example:
[Function("Function1")]
public async Task Run([CosmosDBTrigger(
databaseName: "%COSMOS_RAW_DATABASE%",
containerName: "%COSMOS_RAW_CONTAINER_NAME%",
Connection = "CONNECTION-COSMOS",
LeaseContainerName = "leases",
CreateLeaseContainerIfNotExists = true)] IReadOnlyList<object> input)
{
databaseName, containerName, and Connection all should be driven from configuration. Ideally, databaseName and containerName will come from App Configuration and CONNECTION-COSMOS will come from Keyvault.
This function definition works if I have everything in local.settings.json (run locally) and in app settings of the function resource when deployed. However, I want to avoid storing in the settings in the resources appsettings.
When I try to set up Keyvault and App configuration as configuration providers, it works just fine but the functions seem to launch before I get in to Program.cs / Main so the configuration is not available and I get messages like this (below).
Does anyone have any guidance on how to set this up using configuration from Keyvault and App Configuration?
NOTE: I'm observing the same behavior both locally and deployed
Azure Functions Core Tools
Core Tools Version: 4.0.3971 Commit hash: d0775d487c93ebd49e9c1166d5c3c01f3c76eaaf (64-bit)
Function Runtime Version: 4.0.1.16815
[2021-11-11T00:37:51.846Z] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.Function1'. Microsoft.Azure.WebJobs.Host: '%COSMOS_RAW_DATABASE%' does not resolve to a value.
[2021-11-11T00:37:51.862Z] Error indexing method 'Functions.Function1'
[2021-11-11T00:37:51.865Z] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.Function1'. Microsoft.Azure.WebJobs.Host: '%COSMOS_RAW_DATABASE%' does not resolve to a value.
[2021-11-11T00:37:51.866Z] Function 'Functions.Function1' failed indexing and will be disabled.