question

PrabhakaranPrabhu-3347 avatar image
0 Votes"
PrabhakaranPrabhu-3347 asked MikeUrnun commented

.NET 5 Azure Function (dotnet-isolated) - Input binding from keyvault

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()


dotnet-csharpazure-functionsazure-queue-storage
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers