Introduction to App Settings in Azure Web Apps

DZone 's Guide to

Introduction to App Settings in Azure Web Apps

· ·
Free Resource

In the recent post we talked about Defining and Using Connection Strings in web apps for securing our login credentials of database or any crucial things. Today we will talk about App Settings which is similar to Connection Strings but is used for different purposes. For example connection strings is used for connecting your Web App to Database or Server or any similar things. But App Settings is used to define the mechanism of the Web Apps. You might want to change the behavior of your Web App or something same like that then you can probably go with App Settings in Azure.

For today I will show you how to change color of Label in ASP.Net basic site. This gives you a very good demonstration and gives you best idea of flexibility of Azure in Web Apps.

Note: I do have a basic ASP.Net site for this demo. You might need to start from new project.

Defining App Settings in Azure Web App

Step 1: In your Azure Portal go to your website’s dashboard then click on Configure Tab.

Website Dashboard

Step 2: Scroll down to App Settings

Step 3: In the list, type a name for the setting in the text box with placeholder text KEY and type a value for the setting in the text box with the placeholder text VALUE.


Step 4: Click Save on the command bar to apply all the changes.


Using an App Settings from .NET

Now that we have created and saved an app settings for the color of label. Now we will use it in our ASP.Net Site which I created earlier. I assume you have already created an Azure .Net Web App or ASP.net site.

Step 1: Open your project and your page where you want the connection string to be retrieved. (I have it on default.aspx)

Step 2: Enter this code snippet in default.aspx.cs page.

using System;

using System.Configuration; // You need this declared

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace ravitestwebsite


    public partial class _default : System.Web.UI.Page


        protected void Page_Load(object sender, EventArgs e)


            string key = "labelColor";

            string colorValue = ConfigurationManager.AppSettings[key];

            label.Text = "I got my color from Azure.";

            label.ForeColor = System.Drawing.Color.FromName(colorValue);




In default.aspx page add a label in the site as following.

<asp:Label runat="server" id="label"></asp:Label>

Step 3: Now publish your site to Azure and run it.


Let’s change the color and deploy it and see the changes.

See guys how easy it is to use app settings. This is a basic example. Just think in what ways this can be used. The power of Azure in unbelievable. If you got any query or any idea regarding how to use this. Comment down below.


asp.net, azure, azure web sites, cloud

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}