I created an azure function and it works fine locally. Deployment via Azure Devops also worked perfectly fine under the consumption plan.
I used the Application settings to store my storage name and keys by linking with Azure Key vault.
Also I deployed the same function using the same Devops pipeline into an App Service Plan. This time the function is not able to read the environment variables.
I coped the environment variables from the Consumption plan configuration as its the same function but deployed under different configuration. Also I double checked for any possible spaces and there is nothing different in the variable names and values.
This is how my environment variables look like
{
"name": "01.STORAGE_ACCOUNT_NAME",
"value": "@Microsoft.KeyVault(SecretUri=https://test.vault.azure.net/secrets/Storage-connection-string/abc1)",
"slotSetting": false
},
{
"name": "02.STORAGE_ACCOUNT_KEY",
"value": "@Microsoft.KeyVault(SecretUri=https://test.vault.azure.net/secrets/Storage-connection-string/abc2)",
"slotSetting": false
},
{
"name": "03.STORAGE_CONNECTION_STRING1",
"value": "@Microsoft.KeyVault(SecretUri=https://test.vault.azure.net/secrets/Storage-connection-string/abc3)",
"slotSetting": false
},
{
"name": "04.CONTAINER_NAME",
"value": "abc4",
"slotSetting": false
}
The same format is used in my consumption plan. Since they are validated from the Key Vault I'm also able to see a green validation mark next to them.
Both functions has their Managed identity enabled.
Also, the Key vault access policy has been configured to authorize the 2 functions with "Get & List" permission.
When I try to read the environment variables, I get the result as below
Solution:
When I remove the numbers in front of the variable names and the dot, the function under App Service plan is able to read and return the environment variables defined. Seems like issue is with the naming convention of the variables in the Application settings of the function app. When I revert back the names as to its original state then the function app returns null values.
Every time after changing the Application settings, I restart the function app from the portal for the changes to reflect.
Questions
Why is this different between apps deployed under Consumption and App Service Plan, in terms of the Application setting variables?
Is there any document that explains this?