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:
- Open the Azure Management Portal via https://portal.azure.com
- Navigate to the Web App within the portal.
- Under “All settings” open up the “Application settings” pane
- Scroll down to the “App settings” section
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
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");