03 - Configuration (Flex 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 |
Flex Consumption plan basics
Flex Consumption (FC1) keeps serverless economics while adding VNet integration, configurable instance memory (512 MB to 4096 MB), and per-function scaling. Microsoft recommends it for many new apps.
What You'll Build¶
You will standardize .NET isolated worker app settings for Flex 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"
FUNCTIONS_WORKER_RUNTIME is platform-managed
On Flex Consumption, FUNCTIONS_WORKER_RUNTIME is set by the platform during az functionapp create. You cannot override it via app settings, unlike Consumption where you set it manually.
Step 3 - 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 4 - Verify effective settings¶
az functionapp config appsettings list \
--name "$APP_NAME" \
--resource-group "$RG" \
--output table
Step 5 - 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.23",
"os": "Linux",
"environment": "production",
"functionApp": "func-dnetflex-04100301"
}
Verification¶
App settings output (showing key fields):
Name Value SlotSetting
---------------------------------------- --------------------------------------------------- -----------
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
APP_ENV production False
AZURE_FUNCTIONS_ENVIRONMENT Production 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