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:
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:
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:
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:
And define its value within parameters file:
Once its done, let’s do association for web application using below code:
Again, to deploy same settings for slot would require a slightly different code.
Below is a sample of settings after deployment:
Below is a full copy of the ARM template: