Azure function- application settings

ash 66 Reputation points
2022-10-26T05:13:05.947+00:00

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

254172-image.png

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?

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,448 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MikeUrnun 9,777 Reputation points Moderator
    2022-10-27T23:10:57.343+00:00

    Hello @ash - In this documentation, under Step 4 of Configure App Settings section, the following is stated about the use of period (.) in App setting names:

    App setting names can't contain periods (.). If an app setting contains a period, the period is replaced with an underscore in the container.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.