03 - Configuration (Consumption)¶
Apply environment settings, runtime configuration, and host-level options so the same artifact can run across environments.
Prerequisites¶
| Tool | Version | Purpose |
|---|---|---|
| .NET SDK | 8.0 (LTS) | Build and run isolated worker functions |
| Azure Functions Core Tools | v4 | Start local host and publish artifacts |
| Azure CLI | 2.61+ | Provision Azure resources and inspect app state |
Consumption plan basics
Consumption (Y1) is serverless with scale-to-zero, up to 200 instances, 1.5 GB memory per instance, and a default 5-minute timeout (max 10 minutes).
What You'll Build¶
You will standardize .NET isolated worker app settings for Consumption, keep environment-specific values outside the artifact, and verify effective configuration from Azure.
flowchart TD
A[local.settings.json] --> B[App Settings in Azure]
B --> C[Functions host]
C --> D[dotnet-isolated worker startup]
D --> E[Function method behavior] Steps¶
Step 1 - Baseline local settings¶
The reference app includes a local.settings.json.example template:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"QueueStorage": "UseDevelopmentStorage=true",
"EventHubConnection": "Endpoint=sb://placeholder.servicebus.windows.net/;SharedAccessKeyName=placeholder;SharedAccessKey=cGxhY2Vob2xkZXI=;EntityPath=events"
}
}
Local vs Azure settings
local.settings.json is used only for local development. In Azure, app settings are stored as environment variables in the Function App configuration.
Step 2 - Configure app settings in Azure¶
az functionapp config appsettings set \
--name "$APP_NAME" \
--resource-group "$RG" \
--settings \
"APP_ENV=production" \
"AZURE_FUNCTIONS_ENVIRONMENT=Production"
Step 3 - Set runtime guardrails¶
az functionapp config appsettings set \
--name "$APP_NAME" \
--resource-group "$RG" \
--settings \
"FUNCTIONS_EXTENSION_VERSION=~4" \
"FUNCTIONS_WORKER_RUNTIME=dotnet-isolated"
Step 4 - Review Program.cs for isolated hosting¶
Ensure the host builder uses the ASP.NET Core integration model:
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureServices(services =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
})
.Build();
host.Run();
Isolated worker model
The .NET isolated worker uses ConfigureFunctionsWebApplication() with ASP.NET Core integration. HTTP functions use HttpRequest and IActionResult from ASP.NET Core, and logging is constructor-injected with ILogger<T>.
Step 5 - Verify effective settings¶
az functionapp config appsettings list \
--name "$APP_NAME" \
--resource-group "$RG" \
--output table
Step 6 - Verify runtime behavior with info endpoint¶
The /api/info endpoint reads environment variables at runtime, confirming the deployed configuration:
{
"name": "azure-functions-dotnet-guide",
"version": "1.0.0",
"dotnet": ".NET 8.0.21",
"os": "Linux",
"environment": "production",
"functionApp": "func-dotnetcon-04100220"
}
Verification¶
App settings output (showing key fields):
Name Value SlotSetting
---------------------------------------- --------------------------------------------------- -----------
FUNCTIONS_WORKER_RUNTIME dotnet-isolated False
FUNCTIONS_EXTENSION_VERSION ~4 False
APP_ENV production False
AZURE_FUNCTIONS_ENVIRONMENT Production False
AzureWebJobsStorage DefaultEndpointsProtocol=https;AccountName=... False
APPLICATIONINSIGHTS_CONNECTION_STRING InstrumentationKey=<instrumentation-key>;... False
QueueStorage DefaultEndpointsProtocol=https;AccountName=... False
EventHubConnection Endpoint=sb://placeholder.servicebus.windows.net/;...False
Sensitive values in app settings
Connection strings and keys appear in the output. In production, use Azure Key Vault references instead of storing secrets directly in app settings.
Next Steps¶
See Also¶
- Tutorial Overview & Plan Chooser
- .NET Language Guide
- Platform: Hosting Plans
- Operations: Deployment
- Recipes Index