App Settings for Azure Functions

App settings in Azure Functions are key-value pairs that configure your function app. They are critical for managing your application's behavior, connecting to other services, and storing sensitive information.

App settings are available to your function code as environment variables. This document outlines the common app settings and how to configure them.

Common App Settings

Environment Variables

All app settings are exposed as environment variables within your function execution context. You can access them in your code:

Example (C#):


string storageConnectionString = Environment.GetEnvironmentVariable("AzureWebJobsStorage");
if (!string.IsNullOrEmpty(storageConnectionString))
{
    // Use the connection string
}
            

Example (JavaScript):


const storageConnectionString = process.env.AzureWebJobsStorage;
if (storageConnectionString) {
    // Use the connection string
}
            

Managing App Settings

You can manage app settings through the Azure portal, Azure CLI, or programmatically.

Azure Portal

  1. Navigate to your Function App in the Azure portal.
  2. Under Settings, select Configuration.
  3. Go to the Application settings tab.
  4. Add or edit your key-value pairs.
  5. Click Save.

Azure CLI

Use the az functionapp config appsettings set command:


az functionapp config appsettings set --name <YourFunctionAppName> --resource-group <YourResourceGroup> --settings AzureWebJobsStorage="<YourStorageConnectionString>"
            

Best Practices

Security Note: Never hardcode sensitive information like connection strings or API keys directly in your code. Use app settings or Azure Key Vault for secure storage and retrieval.