I have an Azure function that run in a docker container. This function needs to use an Azure service bus. So my function is using the attribute "ServiceBusAccount" to get the service bus connection string
[FunctionName("MyFunc")]
[ServiceBusAccount("ServiceBusConnectionString")]
public async Task MyFunc(...)
...
In the configuration builder I run the following code to get the some values from the Azure Key Vault (including the Service bus connection string):
var configBuilder = new ConfigurationBuilder();
var config = configBuilder.AddAzureKeyVault($"https://{config["keyVaultName"]}.vault.azure.net", config["keyVaultClientId"], config["keyVaultSecret"])
.Build();
The problem is that while the host is starting up I got first the warning:
"Warning: Cannot find value named 'ServiceBusConnectionString'"
and then after my function is discovered I got this error:
A host error has occurred. Microsoft.Azure.WebJobs.ServiceBus: Microsoft Azure WebJobs SDK ServiceBus connection string 'ServiceBusConnectionString' is missing or empty
My understanding is that the host environment is trying to get the service bus connection string before even starting up the function and before the configuration builder is invoked in the startup class of the project.
Is there any way to set the service bus connection string at runtime?
EDIT
If you are using Azure DevOps this should help to solve this problem https://daniel-krzyczkowski.github.io/How-to-inject-Azure-Key-Vault-secrets-in-the-Azure-DevOps-CICD-pipelines/