Azure Developer Configuration

On This Page

Effective configuration is crucial for deploying, managing, and scaling your applications on Azure. This document outlines key aspects of configuring your Azure resources and applications for optimal performance and maintainability.

General Settings

When setting up Azure services, several general settings dictate their behavior and accessibility. These often include:

Environment Variables

Environment variables are a standard way to pass configuration values to your applications without hardcoding them. Azure services, especially App Service and Azure Functions, provide robust support for managing environment variables.

Setting Environment Variables

You can set environment variables through the Azure portal, Azure CLI, or ARM templates.


# Example using Azure CLI for App Service
az webapp config appsettings set --resource-group MyResourceGroup --name MyWebApp --settings MY_VARIABLE=my_value ANOTHER_VARIABLE=another_value
        

Accessing Environment Variables in Code

Most programming languages provide a way to access environment variables. Here's an example in C#:


string apiKey = Environment.GetEnvironmentVariable("AZURE_API_KEY");
if (apiKey != null)
{
    Console.WriteLine($"API Key: {apiKey}");
}
        

Application Settings

Application settings are key-value pairs that your application code can read at runtime. For PaaS services like Azure App Service and Azure Functions, these settings are often treated similarly to environment variables but are managed within the service's configuration pane.

Common Application Settings

Tip: Use Azure Key Vault to securely store sensitive application settings like connection strings and API keys.

Resource Management

Proper resource configuration ensures efficient usage and cost management. Key aspects include:

Resource Groups

Organize related Azure resources into resource groups for easier management, deletion, and access control.

Tags

Apply tags (key-value pairs) to your resources for categorization, billing, and automation. Common tags include 'Environment' (e.g., 'Development', 'Production'), 'Owner', and 'Project'.


{
  "tags": {
    "Environment": "Production",
    "Project": "Phoenix",
    "Owner": "DevOps Team"
  }
}
        

Monitoring & Logging

Robust monitoring and logging are essential for diagnosing issues, understanding application behavior, and ensuring performance.

Azure Monitor

Leverage Azure Monitor to collect, analyze, and act on telemetry from your Azure and on-premises environments.

Application Insights

An extension of Azure Monitor, Application Insights provides deep diagnostics and performance insights into your live application.

Configuring Diagnostic Settings

You can configure diagnostic settings for most Azure resources to send logs and metrics to destinations like Log Analytics workspaces, Storage Accounts, or Event Hubs.


# Example of configuring diagnostic settings for a Storage Account
az monitor diagnostic-settings create \
    --name 'MyStorageAccountLogs' \
    --resource /subscriptions/YOUR_SUBSCRIPTION_ID/resourceGroups/MyResourceGroup/providers/Microsoft.Storage/storageAccounts/MyStorageAccount \
    --workspace YOUR_LOG_ANALYTICS_WORKSPACE_ID \
    --logs 'category=StorageRead,category=StorageWrite' \
    --metrics 'allRecords'
        

Understanding and implementing these configuration strategies will significantly improve your experience developing and operating applications on Microsoft Azure.