Azure Web app, ARM Templates and what’s missing

ARM templates are a power tool to deploy Azure resources. Whether it’s to recreate a solution or deploy it on a client’s account, it allows for a quick and consistent setup. And, Azure will generate the templates for your resources. That’s a lot of work saved, right?

Azure cannot be exported

Unfortunately, like many Azure features, the tools and documentions are still work in progress. The template generation will not give you the following:

  • Web slots
  • App Settings
  • Connection strings
  • Source control
  • Storage access keys

I will show you how to get it done.

Getting started

You can generate templates automatically from two locations.

On creation of a new resource

When creating a new item, you can click on “Automation options”.
azure automation script
This will give you a single resource template. It is a good starting point to work with.
For example, I selected a web app. This is the template it provided me:

 

From a Resource Group

After creating multiple resource groups, you can go into the Automation script found in its settings. From there, you can download the templates. It will provide you with all the resources that are part of that Resource Group.

 

Now that we are all on the same page, I can show you how to add the missing items. I will be using the example above to add the features.

App Settings to a Web app

To add app settings to our web app, you will need to do the following:

1. Here we have our Web App

2. We will need to add a resources element inside the Web app member and define that new element:

3. Within the properties, you can add the app setting you’d like to have. For example:

Note: dependsOn element tells Azure what resource it should build first based on dependencies. In this case, it’s attached to our website.

Set the GitHub Repository Url for Automatic Deployment

Similar to the App Setting, we need to add the following within Resources element. This will be a recurring theme:

Connection Strings

Here you can add your connection string for your database:

Web Slots

Lastly, web slots are a web site within another web site. Here is an example of a web slot with everything in it.

 

Conclusion

With the above, you can setup your site with one click of a button. It will save you a lot of time deploying or rebuilding your site.

Dernières publications

Laissez un commentaire