The function never reads the latest version of the secret. It always reads the first one it was configured to use, i.e. the versioned one. Even after restarting the function or re-publishing it, it always reads the versioned secret it was first configured to use.
Created a function with a versioned Key vault Reference of the form:
TheSecret
@Microsoft.KeyVault(SecretUri=https://name.vault.azure.net/secrets/TheSecret/__version__)
and in the Function:
if (!int.TryParse(Environment.GetEnvironmentVariable("TheSecret"), out int theSecret))
{
theSecret = 10;
}
The first time the function runs it retrieves the specific version of the secret.
Created a new version of TheSecret
in the Key Vault and change the function application configuation to the non-versioned type:
TheSecret
@Microsoft.KeyVault(SecretUri=https://name.vault.azure.net/secrets/TheSecret/)