Saving a deployment as an ARM template

For this demonstration, we are going to save a deployment as an ARM template from the Azure portal. We are going to export the template of the two VMs that we created in an Availability Set using PowerShell.

Once downloaded, you can then make changes to it, and redeploy it in Azure using PowerShell or code. The generated ARM template consists of a large amount of code, which makes it very difficult to make changes to it. For saving a deployment as an ARM template, take the following steps:

  1. Navigate to the Azure portal by opening https://portal.azure.com.
  2. Open the resource group that we created in the previous demonstration and, under Settings, select the Export template as follows: 

Export template
  1. The template is generated for you based on the settings that we made during the creation of the different resources. You can download the template and redeploy it from here. You can also download the scripts for the CLI, PowerShell, .NET, and Ruby, and create different resources using these programming languages. Select Download from the top menu, as follows:

Download template

The template is downloaded as a ZIP file to your local filesystem. 

  1. You can now extract the template files from the ZIP file and open them in Visual Studio Code. If you don't have this installed, you can use the download link provided at the beginning of this chapter or use Notepad or some other text editing tool. The ZIP file contains three different deployment files, created in different languages. There is one each for PowerShell, the CLI, and Ruby. It also consists of a DeploymentHelper.cs file, a parameters.json file, and a template.json file.
  2. In Visual Studio Code, you can make all of the modifications to the parameters and template files that are needed. If you then want to deploy the template again to Azure, use one of the deployment files inside the container. In the case of PowerShell, right-click on deploy.ps1 and select Run with PowerShell. Fill in the subscription ID, provide the resource group name and deployment name and log in using your Azure credentials. This will start the deployment.

We have now saved a deployment as an ARM template. In the next section, we are going to configure Azure Disk Encryption for VMs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset