{"id":5982,"date":"2017-08-16T10:15:54","date_gmt":"2017-08-16T10:15:54","guid":{"rendered":"https:\/\/blog.cloudthat.com\/?p=5982"},"modified":"2024-06-25T11:11:47","modified_gmt":"2024-06-25T11:11:47","slug":"getting-started-with-authoring-azure-arm-template","status":"publish","type":"blog","link":"https:\/\/www.cloudthat.com\/resources\/blog\/getting-started-with-authoring-azure-arm-template","title":{"rendered":"Getting Started with Authoring Azure ARM Template"},"content":{"rendered":"<p>Automation is a buzzword in modern Cloud Computing world. Various tools and services are available to deploy resources in Cloud. I\u2019m going to discuss about Azure ARM Templates in series of blog articles. In the first part of this article, I\u2019ll be discussing about the benefits of Azure ARM Template, different ways to create Azure ARM Template and how you can kick start deploying templates from Marketplace. So, let\u2019s get started!<\/p>\n<h2><strong>Benefits of Azure ARM Templates:<\/strong><\/h2>\n<p>Azure ARM Template comes with different kinds of benefits, which helps you to automate resource deployment, combine multiple resources under single template and deploy it repetitively. Below are the core benefits of ARM Templates:<\/p>\n<ul>\n<li>Deploying Multiple Resources Using Template<\/li>\n<\/ul>\n<p>Using ARM Templates, you can combine different kind of resources under one template and deploy it based on your architecture.\u00a0 A single script can hold all the configuration of resources.<\/p>\n<ul>\n<li>Redeploy the Same Template:<\/li>\n<\/ul>\n<p>One of the biggest advantage is, you can repeat the cycle of deploying resources again and again using the same template. So, build once and deploy it multiple times. You can create different templates for different kind of workload, for example create separate templates for dev, stage and prod environment and redeploy it as and when required.<\/p>\n<ul>\n<li>Creating Template via Marketplace or Build your Own Template<\/li>\n<\/ul>\n<p>To kick start with template creation, you can create it on your own or you can deploy resources from preconfigured template. Azure has many preconfigured templates in Marketplace, that are tested, verified and made available to deploy resources with pre-defined configuration.<\/p>\n<p>If you are good at templatizing resources and have idea about property configuration, then you can create your own custom template. You can also publish that template to Marketplace and make it available for public usage or you can release it as paid template.<\/p>\n<ul>\n<li>Template Dependencies<\/li>\n<\/ul>\n<p>When deploying resources, you may have one main template with several sub templates with dependencies and deploy resources with customized solution.<\/p>\n<ul>\n<li>Export Template from Existing Resource Group<\/li>\n<\/ul>\n<p>One of the biggest advantage is that, you can deploy all the resources using Azure portal and export ARM Template from the portal. This will help you to redeploy the same resource again and again. You can also export template using entire resource group, so in future you can have all the resources deployed in the same resource group.<\/p>\n<p>ARM Template is based on JSON (JavaScript Object Notation). JSON is one of the simplest descriptive scripting language, that allows you to define key value pair and configure resources.<\/p>\n<p>You can deploy templates using different methods as follows:<\/p>\n<ul>\n<li>Azure Marketplace, from GitHub or you can use your own repository to deploy<\/li>\n<li>Using Azure Portal<\/li>\n<li>Using Azure PowerShell<\/li>\n<li>Using Azure CLI<\/li>\n<\/ul>\n<h2><strong>Using Azure Marketplace or GitHub:<\/strong><\/h2>\n<p>Azure Marketplace or GitHub, using one of these options you can deploy preconfigured ARM Template. These templates are developed, tested and made available in Marketplace for public usage. You can also build your own template and publish it for other people to use it. Marketplace or GitHub consists of simple to complex environment templates to deploy resources in your Azure subscription. To do so follow the below steps:<\/p>\n<p><strong>Step 1:<\/strong> Click on this URL: <a href=\"https:\/\/github.com\/Azure\/azure-quickstart-templates\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/Azure\/azure-quickstart-templates<\/a> to view ARM Templates.<\/p>\n<p>To begin with, search for <a href=\"https:\/\/github.com\/Azure\/azure-quickstart-templates\/tree\/master\/101-vm-simple-windows\" target=\"_blank\" rel=\"noopener\">101-vm-simple-windows<\/a> template. You will get below list of simple VM launch options:<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/VM_launch_options-e1502875838197.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5986 alignnone\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/VM_launch_options-e1502875838197.png\" alt=\"\" width=\"800\" height=\"149\" \/><\/a><\/p>\n<p>Once you click on the template you will get below landing page:<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/VM_launch_options_landing_page-e1502876003507.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5988 alignnone\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/VM_launch_options_landing_page-e1502876003507.png\" alt=\"\" width=\"800\" height=\"360\" \/><\/a><\/p>\n<p>There are two options to explore ARM Template:<\/p>\n<p><strong>Deploy to Azure Button:<\/strong> To deploy template, click on this button which will redirect you to <a href=\"https:\/\/portal.azure.com\" target=\"_blank\" rel=\"noopener\">https:\/\/portal.azure.com<\/a>. Use your Azure credentials to login and deploy VM resource.<\/p>\n<p><strong>Visualize Button:<\/strong> This button will take you to a page, where you can visualize the template architecture and identify how the resources are linked with each other.<\/p>\n<p><strong>Step 2: <\/strong>Once you click on <strong>Deploy to Azure<\/strong> button you will get redirected to Azure portal. Sign in with your Azure credentials and you will jump on to below blade:<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/deploy_to_azure.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5989 alignnone\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/deploy_to_azure.png\" alt=\"\" width=\"788\" height=\"644\" \/><\/a><\/p>\n<p>Provide all the required details like:<\/p>\n<ul>\n<li>Subscription name under which you want to deploy VM<\/li>\n<li>Create new resource group with the name of \u201c<strong>vmdeployment<\/strong>\u201d<\/li>\n<li>Select appropriate location under which region you want to deploy VM. As a best practice, make sure to launch resources nearby customer\u2019s location to avoid latency<\/li>\n<li>Provide Admin username and password which you can easily remember<\/li>\n<li>Choose DNS Label as prefix to access resource vis DNS<\/li>\n<li>Select appropriate OS from the list, I have selected \u201c<strong>2016-Datacenter<\/strong>\u201d<\/li>\n<li>Finally, select checkbox with terms and conditions and click on Purchase button<\/li>\n<\/ul>\n<p>After completing all the steps, you will see the progress of resource deployment:<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/resource_deployement.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5990 alignnone\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/resource_deployement.png\" alt=\"\" width=\"646\" height=\"658\" \/><\/a><\/p>\n<p>Once the process gets completed, VM gets deployed under the <strong>vmdeployment <\/strong>resource group:<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/VM_deployment-e1502876495975.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5991 alignnone\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/VM_deployment-e1502876495975.png\" alt=\"\" width=\"800\" height=\"418\" \/><\/a><\/p>\n<h2><strong>Using Azure Portal:<\/strong><\/h2>\n<p>In the above example, we have seen how to deploy template from preconfigured template. You can also write your own template and deploy resources. To do so, follow the below steps:<\/p>\n<p><strong>Step 1: <\/strong>Log in to <a href=\"https:\/\/portal.azure.com\" target=\"_blank\" rel=\"noopener\">https:\/\/portal.azure.com<\/a> with Azure credentials and click on <strong>New<\/strong> and then search for Template deployment:<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/telplate_deployment.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5992 size-full alignnone\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/telplate_deployment-e1502876984407.png\" alt=\"\" width=\"289\" height=\"500\" \/><\/a><\/p>\n<p><strong>Step 2: <\/strong>Click on <strong>Create<\/strong> button to create custom template:<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/telplate_deployment_1-e1502877169370.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5993 alignnone\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/telplate_deployment_1-e1502877169370.png\" alt=\"\" width=\"482\" height=\"500\" \/><\/a><\/p>\n<p><strong>Step 3: <\/strong>You have multiple options to create template. Out of all the below options, click on <strong>Build your own template in the editor<\/strong> and you will jump on to the blank template:<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/telplate_deployment_2-e1502877313753.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5994 alignnone\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/telplate_deployment_2-e1502877313753.png\" alt=\"\" width=\"800\" height=\"441\" \/><\/a><\/p>\n<p><strong>Step 4: <\/strong>To add new resource, click on <strong>+Add resource <\/strong>button and select a <strong>Windows virtual machine<\/strong>:<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/telplate_deployment_3-e1502877677769.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5995 alignnone\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/telplate_deployment_3-e1502877677769.png\" alt=\"\" width=\"463\" height=\"500\" \/><\/a><\/p>\n<p><strong>Step 5: <\/strong>Provide appropriate details to create new template like name of resource, storage account name, virtual network name and click on <strong>OK<\/strong>.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/telplate_deployment_4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5996 alignnone\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/telplate_deployment_4.png\" alt=\"\" width=\"488\" height=\"440\" \/><\/a><\/p>\n<p><strong>Step 6: <\/strong>You will see that new resource details gets updated in the blank template:<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/telplate_deployment_5-e1502877953113.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5997 alignnone\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/telplate_deployment_5-e1502877953113.png\" alt=\"\" width=\"800\" height=\"444\" \/><\/a><\/p>\n<p>Click on <strong>Save<\/strong> button and proceed further to deploy VM.<\/p>\n<p><strong>Step 7: <\/strong>If you wish to edit or change any information in the template, you can click <strong>Edit template<\/strong> to change or modify values. Provide all the required details to create VM on the below screen:<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/custom_deployment-e1502878111351.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5998 alignnone\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/custom_deployment-e1502878111351.png\" alt=\"\" width=\"610\" height=\"500\" \/><\/a><\/p>\n<p>After submitting all the parameters, you can click on <strong>Purchase<\/strong> and launch VM.<\/p>\n<h2><strong>Using PowerShell:<\/strong><\/h2>\n<p>PowerShell is one of the scripting tool which you can use for deploying, configuring and deleting resources. You can deploy ARM Templates using PowerShell as well. Here, the commands are slightly different than regular Windows commands. You must configure Azure PowerShell modules and write scripts to work with Azure resource deployment. If you are setting up PowerShell first time, then <a href=\"https:\/\/docs.microsoft.com\/powershell\/azureps-cmdlets-docs\/\" target=\"_blank\" rel=\"noopener\">Click here to setup PowerShell<\/a>.<\/p>\n<p>Once you\u2019re done with configuring Azure PowerShell modules, follow below steps to deploy ARM Template to provision Azure Storage resource.<\/p>\n<p><strong>Step 1: <\/strong>Here I am using sample template from GitHub, <a href=\"https:\/\/github.com\/Azure\/azure-quickstart-templates\/blob\/master\/101-storage-account-create\/azuredeploy.json\" target=\"_blank\" rel=\"noopener\">click here<\/a> to copy JSON code to deploy storage account. Copy code and paste it in any text editor. If you\u2019re familiar with Visual Studio you can use that for editing template.<\/p>\n<p>Save the file with <strong>.json<\/strong> extension:<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/save_json.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5999 alignnone\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/save_json.png\" alt=\"\" width=\"672\" height=\"476\" \/><\/a><\/p>\n<p><strong>Step 2: <\/strong>To launch template using PowerShell, open your PowerShell cmdlet and type below command to log in to your Azure subscription:<\/p>\n<p><code>Login-AzureRmAccount<\/code><\/p>\n<p>This command will prompt you with a dialogue box to login.<\/p>\n<p><strong>Step 3:<\/strong> After logging in to subscription, type below command to provision a storage account:<br \/>\n<code>New-AzureRmResourceGroup -Name ResourceGroupName -Location \"East US\"<\/code><br \/>\n<code>New-AzureRmResourceGroupDeployment -Name NameOfDeployment -ResourceGroupName ResourceGroupName -TemplateFile JSONFilePath -storageAccountType Standard_GRS<\/code><\/p>\n<p>Provide appropriate details like ResourceGroupName, location and path of JSON file to deploy template. Once you finish above steps, you will get below status on PowerShell screen:<\/p>\n<p>ProvisioningState: Succeeded<\/p>\n<p>Using Azure CLI:<br \/>\nIf you are working on macOS, Linux or Windows OS, you can install Azure CLI package by clicking on this link. I have followed the same steps to create storage account using Azure CLI commands.<\/p>\n<p>To login with Azure subscription use:<br \/>\n<code>az login<\/code><\/p>\n<p>For creating storage account:<br \/>\n<code>az group create --name resourcegroupname --location \"East US\"<\/code><br \/>\n<code>az group deployment create --resource-group resourcegroupname --template-file JSONFilePath<\/code><\/p>\n<p>Let me know what do you think by providing comments in the comments section.<\/p>\n<p>If you would like to learn more about Azure ARM Template, then you would want to check out <a href=\"https:\/\/cloudthat.in\/?utm_source=blog-website&amp;utm_medium=text-link&amp;utm_campaign=training-website\" target=\"_blank\" rel=\"noopener\">CloudThat\u2019s<\/a> newly launched course i.e. <a href=\"https:\/\/cloudthat.in\/course\/authoring-azure-arm-templates\/?utm_source=blog-website&amp;utm_medium=text-link&amp;utm_campaign=authoring-azure-arm-templates\" target=\"_blank\" rel=\"noopener\">Authoring Azure ARM Template<\/a>. This course focuses on how to design and deploy ARM Template from scratch and automate resource deployment in Azure. You will also learn to configure custom parameters, setting up variable, securing resources using RBAC. This course will also help participants to prepare for one of the exam objectives that is,\u00a0<strong>Design and Deploy ARM Templates<\/strong>\u00a0which is part of the 70-533 exam: Implementing Microsoft Azure Infrastructure Solutions.<a href=\"https:\/\/cloudthat.in\/?utm_source=blog-website&amp;utm_medium=text-link&amp;utm_campaign=training-website\" target=\"_blank\" rel=\"noopener\">Check it out.<\/a><\/p>\n","protected":false},"author":219,"featured_media":6002,"parent":0,"comment_status":"open","ping_status":"open","template":"","blog_category":[3608,3607],"user_email":"prarthitm@cloudthat.com","published_by":"324","primary-authors":"","secondary-authors":"","acf":[],"_links":{"self":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/5982"}],"collection":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/users\/219"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/comments?post=5982"}],"version-history":[{"count":1,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/5982\/revisions"}],"predecessor-version":[{"id":45782,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/5982\/revisions\/45782"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/media?parent=5982"}],"wp:term":[{"taxonomy":"blog_category","embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog_category?post=5982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}