0 Comments

Saving a deployment as an ARM template

Now that we know how to deploy resources from custom RBAC templates, let’s see how to save an existing deployment to an ARM template via the Azure portal:

  1. Navigate to the Azure portal by opening a web browser and going to https:// portal.azure.com.
  2. In the left menu, selectResource groups and select your resource group. In my scenario, I’m going to use the Production_RG resource group:

Figure 9.15 – Azure resource groups

  1. On the Automation tab of the resource group, select Export template:

Figure 9.16 – Exporting resources as an ARM template

  1. Next, select Download, and the ARM template will download, which can then be used to redeploy resources, and amended to create custom resources:

Figure 9.17 – Downloading the ARM templates for existing resources

In this section, we had a look at how to export all existing resources within a resource group to an ARM template via the Azure portal.

We encourage you to read up further by using the following links based on Azure ARM templates:

• https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/export-template-portal

• https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/export-template-cli

• https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/export-template-powershell

In the next section, we are going to have a look at how to deploy VM extensions.

Tip

You can save a deployment from a resource group or a single resource to an ARM template.

Deploying VM extensions

VM extensions are applications that we can install as part of the script or post-deployment. An example of this would be adding antimalware applications to a VM. VM extensions can be configured for existing and future deployments.

Let’s look at how to configure the Microsoft Antimalwareextension to an existing

Windows VM:

  1. Navigate to the Azure portal by opening a web browser and going to https:// portal.azure.com.
  2. In the left menu, selectVirtual machines and select your VM that we deployed with our script in the Deploy from a template section of this chapter:

Figure 9.18 – Selecting a VM

  1. Under the Settings tab, select Extensions and click on add on the next page:

Figure 9.19 – Selecting the Extensions tab

  1. Now, scroll down and select the Microsoft Antimalwareextension and click on Create:

Figure 9.20 – Creating the Microsoft Antimalware extension for the selected VM

  1. Next, we can choose the antimalware settings; for this scenario, we are going to leave it at the default settings, and click OK:

Figure 9.21 – Extension configuration options

  1. Once the extension has successfully been deployed, it will show along with other extensions configured for the VM:

Figure 9.22 – Successfully deployed Microsoft Antimalware extension

In this section, we had a look at how to deploy VM extensions via the Azure portal.

We encourage you to read up further by using the following link based on Azure VM extensions: https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/overview.

Important Note

You can only add VM extensions if the VM is running.

Summary

In this chapter, we discussed how to modify ARM templates and how to configure an ARM template with a VHD. We addressed how to deploy from an ARM template via the Azure portal. Lastly, we addressed how to configure VM extensions. After reading this chapter and following along with the hands-on demos, you should now be able to deploy IaC via ARM templates and work with Azure infrastructure deployments.

In the next chapter, we’ll cover how to configure VMs with hands-on examples.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts