'KeyVaultSecretsRepository vaultUri ArgumentException

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


Solution 1:[1]

You probably have the App setting "AzureWebJobsSecretStorageType" set to "keyvault"? (To store your function keys in a key vault instead of storage)

Looks like (sinds .net6) you now have to add the App setting "AzureWebJobsSecretStorageKeyVaultUri" with your key vault url instead of the "AzureWebJobsSecretStorageKeyVaultName" with the name of your key vault.

You can remove the "AzureWebJobsSecretStorageKeyVaultName" setting...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eelco Koster