Azure / Azure/azure-functions-dotnet-worker
Expose configuration from worker processes
- Dominant language
- C#
- Stars
- 466
- Forks
- 215
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 7
Description
I am trying to connect my function app to keyvault and get queue name and connection secrets. This was working well with .netcore3.1 app using the ConfigureAppConfiguration(IFunctionsConfigurationBuilder builder) method in FunctionStartup.
After upgrading to .net5 dotnet-isolated, the bindings does not work. I configured azurekeyvault in Program.cs but still it does not pick from keyvault. Seems like functionstartup is trying to bind before Main() is invoked.
**QueueFunction**
public static void Run([QueueTrigger("%QueueName%", Connection = "QueueConnection")] string message, string id)
**Startup.cs (.netcore3.1)- working**
public override void ConfigureAppConfiguration(IFunctionsConfigurationBuilder builder)
{
var azureKeyVaultURL = Environment.GetEnvironmentVariable("AzureKeyVaultURL");
var azureKeyVaultADAppID = Environment.GetEnvironmentVariable("AzureKeyVaultMIAppID");
builder.ConfigurationBuilder
.SetBasePath(Environment.CurrentDirectory)
.AddAzureKeyVault(new Uri(azureKeyVaultURL), new ManagedIdentityCredential(azureKeyVaultADAppID))
.AddEnvironmentVariables()
.Build();
}
**Program.cs (.net5)- Not working**
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureAppConfiguration(config =>{
var azureKeyVaultURL = Environment.GetEnvironmentVariable("AzureKeyVaultURL");
var azureKeyVaultADAppID = Environment.GetEnvironmentVariable("AzureKeyVaultMIAppID");
config
.SetBasePath(Environment.CurrentDirectory)
.AddAzureKeyVault(new Uri(azureKeyVaultURL), new ManagedIdentityCredential(azureKeyVaultADAppID))
.AddEnvironmentVariables()
.Build();
})
.Build()
Contributor guide
No contributing guide indexed for this repository
Research direction
Compare the .NET Core Startup.cs configuration path with Program.cs in the .NET 5 isolated worker, focusing on ConfigureFunctionsWorkerDefaults and ConfigureAppConfiguration. Reproduce the QueueFunction binding with QueueName and QueueConnection values from Azure Key Vault; done means those bindings resolve before invocation in the isolated worker.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- backend, cloud
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100