Configure application settings for Azure Web App using Azure ARM template

In last post, we have discussed how to create azure web app along with the deployment slots using Azure ARM template. We are going to expand on the template created and learn how to configure application settings, web app properties like alwaysOn, remote debugging, etc and connection strings for azure web app in this blog post.

Define Web App Properties

Method 1: Use of Object variables
Variables are not only useful for declaring text that is used in multiple places and standardize them; they can be objects as well. This is especially handy in case you want to create multiple web apps in your template and apply common settings to them all.

Below is one of the sample code we can use:

ARM code to define object type variable
ARM code to define object type variable

Now, we need to associate the properties with web app and also to the deployment slot. For that, we can simple go to the resources array and add below code:

ARM code to apply application configuration from variables
ARM code to apply application configuration from variables

Note that the code will vary a little for slot configuration, as it needs to be altered to suit to its parent. Below snip shows application settings will look like once you deploy web app using above code:

Application settings from azure portal after deployment of arm template
Application settings from azure portal after deployment of arm template

Method 2: Use of Object parameters
Not only variables but parameters can have a object type too. This is very useful to apply multiple settings for a particular web application. It is most commonly use to deploy connection strings and application settings. Again, you can define properties like alwaysOn, remote debugging etc by making use of parameters, instead of variables as well. One of the examples of using object parameters is discussed as below where we define application and connection strings.

Define Application Settings and Connection Strings

Since application settings are specific to a web app, we would generally make use of a object parameter type as mentioned above. First, let’s define a complex parameter type in main resource definition file:

ARM code to define object type parameter
ARM code to define object type parameter

And define its value within parameters file:

ARM code for defining web app application settings
ARM code for defining web app application settings

Once its done, let’s do association for web application using below code:

ARM Code to define application settings and connecting strings
ARM Code to define application settings and connecting strings

Again, to deploy same settings for slot would require a slightly different code.
Below is a sample of settings after deployment:

Application settings from azure portal - 2
Application settings from azure portal – 2

Below is a full copy of the ARM template:

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