Learn Azure Administration
上QQ阅读APP看书,第一时间看更新

Automation scripts

If you have provisioned resources manually, there is a way to generate an automation script from the whole resource group. To do so, follow these steps:

  1. Go to your resource group and click on the Export template blade:
Figure 2.7: Export template blade
In the newest version of the portal, the Automation script  option has been renamed to Export template.
  1. You will see a new window where you can find the whole ARM template. This can be exported. What's more, this feature generates four additional scripts that can be used if you do not like JSON templates:
    • CLI
    • PowerShell
    • .NET
    • Ruby

All are equally functional, so it is only a matter of preference.

  1. In the following screenshot, we can see that the generated template is much more complex as it contains all the possible parameters that can be set for a resource:
Figure 2.8: ARM template generated from the portal

From my experience, I can tell that using such a generated template is a good starting point, but unfortunately, there are situations where such templates will contain errors (because a parameter was not exported or exported partially). This is why it is a good idea to perform a quick check of it by clicking on the Deploy button that's available on the blade.

Exporting a template for deployed resources is a good idea, especially when starting with a proof-of-concept and proceeding to a more mature solution. In your daily work, this approach may have too many cons and you need a tool that will help you introduce logic or deploy resources in a more flexible way. This is why, in the next section, we will cover some extra tools that may suit your needs.