After 2 successfull local upgrades of azure function apps to dotnet 6, both fail with the same error when upgrade PR deployed in Azure.
vaultUri ArgumentException
at Microsoft.Azure.WebJobs.Script.WebHost.KeyVaultSecretsRepository..ctor (Microsoft.Azure.WebJobs.Script.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\Security\KeyManagement\KeyVaultSecretsRepository.cs:38)
Version of .net went from core 3 to 6 (not isolated) and and functions v3 to v4. We are using ARM templates in Azure Devops to deploy, there are no other changes other than bumping up the versions of dotnet, functions and NuGets and fixing some code warnings.
Looking at .net source code its failing on
Uri keyVaultUri = string.IsNullOrEmpty(vaultUri) ? throw new ArgumentException(nameof(vaultUri)) : new Uri(vaultUri);
CodePudding user response:
Simply going through microsoft source code of Microsoft.Azure.WebJobs.Script.WebHost.DefaultSecretManagerProvider
we can find it's creating a new instance of KeyVaultSecretsRepository
and pass to it the valtUri under the environment name public const string AzureWebJobsSecretStorageKeyVaultUri = "AzureWebJobsSecretStorageKeyVaultUri";
you can add the 'AzureWebJobsSecretStorageKeyVaultUri' configuration key with your Vault URI to your app configuration and that will make it work.