I am currently migrating a dotnet-isolated v3 function (.net 5) to a non-isolated v4 azure function (.net 6)
in v3 dotnet-isolated I had a console application and so a Program.cs
which contained the following code:
public static void Main()
{
var host = new HostBuilder()
.ConfigureAppConfiguration(AddAzureAppConfig)
.Build();
host.Run();
}
private static void AddAzureAppConfig(IConfigurationBuilder builder)
{
var azureAppConfigurationEndpoint = Environment.GetEnvironmentVariable("AzureAppConfiguration");
builder.AddAzureAppConfiguration(options =>
options.Connect(azureAppConfigurationEndpoint).ConfigureKeyVault(kv =>
{
kv.SetCredential(new DefaultAzureCredential());
}).Select(KeyFilter.Any, LabelFilter.Null)
);
}
Now in v4 I have a library instead and so no program.cs. Instead I created a Startup.cs
derived from FunctionsStartup
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddHttpClient();
...
}
}
As far as I understood from this StackOverFlow-Question v4 Azure Functions don't have any IConfigurationBuilder and don't need to if you directly want to access any configuration values.
Now my issue is that while AddAzureAppConfiguration
inside the Microsoft.Extension.Configuration.AzureAppConfigurationExtensions
has a overload I could use (AddAzureAppConfiguration(this IServiceCollection services)
) but it is missing the Action<AzureAppConfigurationOptions> action
parameter (which the IConfigurationBuilder
- variant had) which I need to add the KeyVault options.
What do I have to modify to use the same approach I was using with my AddAzureAppConfig()
that worked on the v3 isolated console application approach?