Azure Web App: Application Settings

All web applications have some kind of configurations necessary. The method of storing and accessing these settings varies on different web application platforms. In ASP.NET they are normally stored within <appSettings> element of the web.config file. The Microsoft Azure Web Apps Service allows for these application settings to be configured within the Azure Web App configurations in the cloud, and then subsequently accessed from application code as needed. With .NET applications the application settings are accessed exactly as AppSettings contained within the web.config file. In other web platforms (Java, Node.js, PHP and Python) the application settings are access via Environment Variables.

Application Settings are stored as a Key / Value pair. These are both stored as String values.

Application Settings within Azure Management Portal

Managing Application Settings for a Microsoft Azure Web App is performed using the Azure Management Portal.

Here are the necessary steps to locate and access the App Settings for an Azure Web App:

  1. Open the Azure Management Portal via https://portal.azure.com
  2. Navigate to the Web App within the portal.
  3. Under “All settings” open up the “Application settings” pane
  4. Scroll down to the “App settings” section

AzureWebApp_AppSettings_Pane

Application Settings from .NET

Accessing the Application Settings from a .NET application is performed using the ConfigurationManager class.

Here’s an example of accessing an Application Setting from C#:

using System.Configuration;

string value = ConfigurationManager.AppSettings["key"];

Application Settings from Node.js

Azure Web App application settings are exposed to Node.js javascript code as Environment Variables. These Environment Variables have the same name as the Application Settings key. Additionally, they can be accessed using the “APPSETTING_” prefix.

Here are 2 examples of accessing the Application Settings from Javascript running on Node.js:

var value1 = process.env.MySettingOne;
var value2 = process.env.APPSETTING_MySettingOne;

Application Settings from Java

Azure Web Application settings are exposed to Java code through Environment Variables. These Environment Variables have the same name as the Application Setting key. Additionally, they can be accessed using the “APPSETTINGS_” prefix.

Here are 2 examples of accessing the Application Settings from Java:

String value1 = System.getenv("MySettingOne");
String value2 = System.getenv("APPSETTING_MySettingOne");

3 thoughts on “Azure Web App: Application Settings

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s