Azure Tips & Tricks - Bootstrap Automation for New resources for repeated deployments in multiple environments
@20aman Jan 15, 2019When you want to automate resource deployment you will either create the automation templates for an existing set of resources or you will create templates for resources that have not been created yet. For the latter situation, e.g. automating the deployment of a new set of resources, you will have to start the automation from scratch. Instead of starting from scratch, you can bootstrap your automation via ARM Templates.
Reuse Existing
You can first search for your resources or scenarios in the Microsoft Quick Start templates. Note that these are sample templates from Microsoft and community members. These templates can be found here: Azure Quickstart Templates.
When you click on a template name you will see multiple files as shown below. Actual template file will always be named as "azuredeploy.json". The related parameters file will be named as "azuredeploy.parameters.json". All other files are optional and are the supporting files for the template.
You can download these files and edit them. You can fork them directly in GitHub and start editing in a source control environment, but your changes will be public (unless you change your repository to Private). If you do not want to make changes and want to directly deploy one of the template, simply click on the "Deploy to Azure" button. This will open Azure portal and you will need to sign into your subscription. Then the template deployment blade will open with the template information already populated. You will just need to select right Subscription, Resource Group and provide various parameters.
It is really simple and saves you lot of time instead of authoring the template from scratch. Why re-invent the wheel. Reuse instead!
Generating template for new resource creation in Azure
If you are creating new resource from the Azure portal and you have to perform this same action multiple times, you should consider using an ARM Template. If you want to create an ARM Template for a resource for which you can't find a template, even then you can use Azure portal to bootstrap the template creation, rather than starting from scratch.
Simple go ahead and start creating your resource from Azure portal. At the last screen, instead of actually creating the resource, look for a link with the name as "Download a template for automation". This will open another blade which will show you the template. You can download the template from here. It will also include the related parameters file and a script to perform the deployment of your template. The below screenshot shows you the option for Storage Account creation.
Note: This option will not be available for all resource types. Microsoft is adding this option to more and more resources everyday.