How to Configure App Settings in Azure App Service
To configure app settings in Azure, go to your Azure App Service in the portal, select
Configuration, then add or edit key-value pairs under Application settings. These settings act like environment variables and are used by your app at runtime.Syntax
App settings in Azure App Service are key-value pairs that you define under the Application settings section. Each setting has a name and a value. These are injected as environment variables into your app.
Example syntax for a setting:
Key: The name of the setting, e.g.,MySettingValue: The value for the setting, e.g.,12345
text
MySetting=12345Example
This example shows how to add an app setting named ConnectionString with a value for your database connection. Your app can then read this setting as an environment variable.
text
1. Open Azure Portal and go to your App Service. 2. Select <strong>Configuration</strong> from the left menu. 3. Under <strong>Application settings</strong>, click <strong>New application setting</strong>. 4. Enter <code>ConnectionString</code> as the name and your connection string as the value. 5. Click <strong>OK</strong> and then <strong>Save</strong> to apply changes. // In your app code (example in C#): string connStr = Environment.GetEnvironmentVariable("ConnectionString");
Output
The app setting is saved and available as an environment variable named 'ConnectionString' when the app runs.
Common Pitfalls
Common mistakes when configuring app settings include:
- Not saving changes after adding or editing settings, so the app does not see updates.
- Using incorrect key names or typos, causing the app to fail reading the setting.
- Storing sensitive data in plain text without using Azure Key Vault integration.
- Expecting changes to apply instantly without restarting the app; sometimes a restart is needed.
csharp
Wrong way: // Typo in key name string connStr = Environment.GetEnvironmentVariable("ConnetionString"); // typo Right way: string connStr = Environment.GetEnvironmentVariable("ConnectionString");
Quick Reference
| Action | Description |
|---|---|
| Add App Setting | Go to App Service > Configuration > Application settings > New application setting |
| Edit App Setting | Select existing setting, change value, then save |
| Delete App Setting | Select setting, click delete, then save |
| Access in Code | Use environment variables with the setting name |
| Secure Secrets | Use Azure Key Vault references for sensitive data |
Key Takeaways
Configure app settings in Azure App Service under Configuration > Application settings.
App settings become environment variables your app can read at runtime.
Always save changes and restart your app if needed to apply new settings.
Avoid typos in key names to prevent runtime errors.
Use Azure Key Vault for storing sensitive information securely.