Search code examples
azureazure-functionsazure-keyvault

Azure CLI command for 'Pull reference values' from Key Vault in a Function App


I have a Function App with a Key Vault reference for an App Setting such as the following:

@Microsoft.KeyVault(SecretUri=https://myvault.vault.azure.net/secrets/mysecret/)

This will pull the latest secret version for mysecret into the Function App Settings according to the rotation policy, which could be up to 24 hours. For referenced secrets that change frequently this delay is not acceptable.

Within Azure Portal the 'Pull reference values' (formally 'Fetch latest values') button may be pressed to sync the secrets:

enter image description here

Does the community know if there is an Azure CLI command that will achieve the same result as this button press so that the process may be automated?

Without this, I believe my only options that could be automated are:

  • Use specific secret versions rather than 'latest'
  • Remove and re-add the offending app setting

Solution

  • You can try to use az rest with post method:

    az rest --method post --url https://management.azure.com/[Resurce ID]/config/configreferences/appsettings/refresh?api-version=2022-03-01
    

    run results