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[&quot;key&quot;];

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(&quot;MySettingOne&quot;);
String value2 = System.getenv(&quot;APPSETTING_MySettingOne&quot;);

Posted by Chris Pietschmann

Chris is a Microsoft MVP and has nearly 20 years of experience building enterprise systems both in the cloud and on-premises. He is also a Certified Azure Solutions Architect (both MCSD and MCSE), a trainer, and Cloud Advocate. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.

3 Comments

  1. […] Azure Web App: Application Settings (Chris Pietschmann) […]

    Reply

  2. […] With Azure Web Apps the Connection Strings are stored/retrieved in a very similar fashion as Azure Web App Application Settings. Connection Strings are also Key / Value pairs of String values, but are separated out into their […]

    Reply

  3. […] specific feature of Azure Web Apps that helps with this is the ability to override application settings and connection strings from within the Azure Portal. This way you could allow your developers or […]

    Reply

Leave a Reply