Azure – Create and Deploy Azure Resource Manager Template using Azure Portal

Hello Friends,

If you missed our following articles on Exam : Developing Microsoft Azure Solutions, Please have a look once here :

Azure –  Remote debugging on an Azure VM

Azure –  Azure Automation State Configuration

Azure – Configure Azure PowerShell Desired State Configuration (DSC) Through Azure Portal

Azure –  Configure Azure PowerShell Desired State Configuration (DSC) Using PoserShell

Azure – Azure Resource Manager (ARM)

In our last blog, we have discussed about Azure Resource Manager (ARM). As We know  that, Azure Resource Manager allow us to generate and use a template to deploy, update, or delete all the resources for a solution in a single operation and  the template is know as ARM Template. Today we will see, how to create and deploy a ARM template using Azure Portal. Let’s proceed step by step and see how it works.

  1. Connect to your Azure portal dashboard using your subscription account. If you don’t have an Azure subscription, create a free account before you begin. Then you can connect to the azure portal dashboard as in following figure.Azure portal dashboard
    Figure 1: Azure Certification 70-532 – portal dashboard
  2. For a better understanding, we have created two different resource groups. “ManasARMTemplatesGroup” will be used as source resource group and the other one “ManasARMDestnation” will be used as destination resource group, where we will deploy our template, as shown in the following figure.
    Both Resource group
    Figure 2: Azure Certification 70-532 – Two Resource Group createdAzure portal dashboard
    Figure 3: Azure Certification 70-532 – Destination Resource Group where template will be deployed
  3.       Before generating the ARM template, let’s create couple of resource in the source resource group. So that when we will generate the template, it will have couple of resources in the template. Here we have created one storage account and one Virtual Machine. Virtual Machine creation, in turn it created few more dependent resources, as in following figure.Multiple resources under source
    Figure 4: Azure Certification 70-532 – Multiple resources under source resource group
  4. Verify all resources, we required in the our template before download the template. To download the resource group template, go to the source resource group (ManasARMTemplatesGroup ) and from resource group page, Click on “Automation script” under “Setting” and click on Download button to download the template, as in following figure.Download template from Resource
    Figure 5: Azure Certification 70-532 – Download template from Resource Group page
  5. After downloading the template as a package, Open template.json file and edit as per the requirement like change the VM name and Storage Account name and save the file. Azure requires that each Azure service has a unique name. The deployment fails if we enter a storage account name that already exists. To avoid this issue, we can also use a template function call uniquestring() to generate a unique storage account name. Here I have set the name with hard coded value, as shown in following figure.torage Account Name should changed
    Figure 6: Azure Certification 70-532 – Storage Account Name should not be duplicate
  6. Once we are ready with our template file, the next step is to deploy the template to create all resources defined in the template. To start with deployment follow the below steps.
  7. If everything went well and deployment will be success otherwise it will fail with error. In our case we have faced following three errors. So I have written following articles for the fixes of the following issues.
  8. After fixing the above issues, we ware able to successfully deploy as shown in the following figure
    successfully deployed
    Figure 9: Azure Certification 70-532 – successfully deployedTo verify, whether we got success with our deployment, lets move to destination resource group and see if all resources created or not as shown in the following figure.
    Resources under Destination resource Group Post deployement
    Figure 10: Azure Certification 70-532 – Resources under Destination resource Group Post deployement

Thanks for reading 🙂

Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more. If you have any suggestion / feedback / doubt, you are most welcome.

Stay tuned on Knowledge-Junction, will come up with more such articles.