Azure Functions App Settings
Application settings are key-value pairs that are stored in your Azure Functions app. These settings are accessible to your functions at runtime and are crucial for configuring your application's behavior, managing connections, and storing sensitive information.
Settings can be configured in several ways:
- Azure Portal: The most common method for interactive configuration.
- Azure CLI: For scripting and automation.
- ARM Templates/Bicep: For infrastructure as code deployments.
- Local.settings.json: For local development and testing.
Accessing App Settings
Within your function code, you can access app settings through environment variables. The name of the environment variable typically corresponds to the name of the app setting.
Example (C#):
string mySettingValue = Environment.GetEnvironmentVariable("MySettingName");Example (JavaScript):
const mySettingValue = process.env.MySettingName;Example (Python):
import os
my_setting_value = os.environ.get("MySettingName")Common App Settings
Here are some commonly used application settings:
| Setting Name | Description | Example Value | 
|---|---|---|
| AzureWebJobsStorage | The connection string for the storage account used by the Functions runtime for internal operations, such as triggering timers, queue processing, and managing leases. This is a required setting. | DefaultEndpointsProtocol=https;AccountName=yourstorageaccount;AccountKey=yourkey;EndpointSuffix=core.windows.net | 
| WEBSITE_NODE_DEFAULT_VERSION | Specifies the Node.js version to use for JavaScript functions. | 18or20 | 
| AzureFunctionsWorkerRuntime | Specifies the runtime for your functions (e.g., dotnet,node,python,java,powershell). | dotnet | 
| APPINSIGHTS_INSTRUMENTATIONKEY | The instrumentation key for Azure Application Insights, used for monitoring and diagnostics. | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | 
| NotificationsEnabled | A custom setting to enable or disable email notifications. | true | 
Managing Settings in the Azure Portal
To manage your app settings in the Azure portal:
- Navigate to your Function App resource.
- In the left-hand menu, under "Settings", select "Configuration".
- You will see two tabs: "Application settings" and "Connection strings".
- Add, edit, or delete your settings as needed.
- Click "Save" to apply your changes. The Function App will typically restart to apply these settings.
Local Development (local.settings.json)
During local development, app settings are typically defined in a local.settings.json file in the root of your project. This file is not deployed to Azure and is used by the Azure Functions Core Tools.
{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "MyCustomSetting": "LocalValue"
  }
}local.settings.json, you can set "IsEncrypted": true and use the Azure Functions Core Tools to encrypt sensitive values.
                Connection Strings
Specific connection strings can be managed under the "Connection strings" tab in the Azure portal's configuration. These are also available as environment variables, but often with a prefix like CUSTOMCONNSTR_ or a predefined name based on the service type (e.g., SQLCONNSTR_).
Best Practices
- Use Meaningful Names: Choose descriptive names for your settings.
- Separate Configuration from Code: Never hardcode configuration values.
- Utilize Azure Key Vault: For highly sensitive information like API keys and database credentials.
- Environment-Specific Settings: Use different settings for development, staging, and production environments.
- Regularly Review: Periodically check your app settings for security and relevance.