{"id":645,"date":"2021-07-04T19:58:04","date_gmt":"2021-07-04T19:58:04","guid":{"rendered":"https:\/\/www.spktechfit.com\/?p=645"},"modified":"2021-07-04T19:58:04","modified_gmt":"2021-07-04T19:58:04","slug":"14-windows-and-linux-vms","status":"publish","type":"post","link":"https:\/\/www.spktechfit.com\/?p=645","title":{"rendered":"14. Windows and Linux VMs"},"content":{"rendered":"<h1>Modify Existing ARM Templates<\/h1>\n<p>What are ARM Templates? <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/azure-resource-manager\/templates\/overview\">https:\/\/docs.microsoft.com\/en-us\/azure\/azure-resource-manager\/templates\/overview<\/a><\/p>\n<p>ARM Templates allow for the automation of Virtual Machines-<\/p>\n<p><i>&#8220;To implement infrastructure as code for your Azure solutions, use Azure Resource Manager templates (ARM templates). The template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax, which lets you state what you intend to deploy without having to write the sequence of programming commands to create it. In the template, you specify the resources to deploy and the properties for those resources.&#8221;<\/i><\/p>\n<h2>Template<\/h2>\n<p>After you deploy a VM, you can get the template used to create that resource. You can find this in the &#8220;Deployments&#8221; section.<\/p>\n<p>When you download the template you get 2 JSON files:<\/p>\n<ul>\n<li><b>Template<\/b>: this is where all of the resources within the deployment get defined. EG: resource group, network adapter, virtual network etc\u2026<br \/>\nThe area you will work in most in the template is the &#8220;Resources&#8221; section.<br \/>\nThere are dependencies within this section. EG: before the network adapter is create the virtual network and NSG must be defined.<\/li>\n<li><b>Parameters<\/b>:\u00a0 this is where the parameters for the deployment are set. EG: location, resource group name, subnet prefix etc\u2026<\/li>\n<\/ul>\n<h2>Editing Template\/Parameters<\/h2>\n<p>Let&#8217;s say you wanted to create a new VM using a template from a VM you already created. You would have to change a couple of items in the Parameters JSON file for this to work. These would be:<\/p>\n<ul>\n<li>VM name<\/li>\n<li>Network adapter name<\/li>\n<li>PublicIP<\/li>\n<\/ul>\n<p>Other parameters can stay the same, such as:<\/p>\n<ul>\n<li>Location<\/li>\n<li>Virtual Network<\/li>\n<li>Resource Group<\/li>\n<\/ul>\n<h2>DSC (Desired State Configurations)<\/h2>\n<p>An example of use for the templates in in DSC.<\/p>\n<p>If you have a Virtual Network configured the way you want it with lots of settings, and want to ensure it keeps these settings, you can use a template with these settings and deploy it every hour. If everything the current Virtual network is the same as in the template, nothing will be changed. But if there are have been changes made to the Virtual Network, the deployment of the template on the hour will revert the settings back to what is in the template.<\/p>\n<h2>Deploying a Template<\/h2>\n<p>When you go to create a new Resource you get the option to use a template.<\/p>\n<p><b>1. Azure Portal<\/b><\/p>\n<ul>\n<li>Go to Templates and you can add your configured template.<\/li>\n<li>Then click on &#8220;Edit Parameters&#8221; and past in your own parameters.<\/li>\n<li>You can deploy the template from here.<\/li>\n<\/ul>\n<p><b>2. Powershell<\/b><\/p>\n<p>You can deploy this using powershell with the Command: New-AzResourceGroupDeployment<\/p>\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/az.resources\/new-azresourcegroupdeployment?view=azps-5.9.0\">https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/az.resources\/new-azresourcegroupdeployment?view=azps-5.9.0<\/a><\/p>\n<p>&nbsp;<\/p>\n<h1>ARM Custom Script Extensions<\/h1>\n<p>This allow you to deploy software and make other changes post deployment.<\/p>\n<p>You can add paths to scripts in the ARM template so they run once the VM has been deployed.<\/p>\n<p>&nbsp;<\/p>\n<h1>ARM Using VHD<\/h1>\n<p>Another method of deploying a VM with preconfigured software is to use a VHD. You can have a drive already setup with the necessary software and configurations, then when deploying the new VM with an ARM template you supply the VHD Uri link and it will use that as the drive for the VM.<\/p>\n<p>&nbsp;<\/p>\n<h1>ARM Templates for Almost Anything<\/h1>\n<p>The official Microsoft Azure GitHub repository contains sample ARM templates for almost every service in Azure:<\/p>\n<p><a href=\"https:\/\/github.com\/Azure\/azure-quickstart-templates\">https:\/\/github.com\/Azure\/azure-quickstart-templates<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Modify Existing ARM Templates What are ARM Templates? https:\/\/docs.microsoft.com\/en-us\/azure\/azure-resource-manager\/templates\/overview ARM Templates allow for the automation of Virtual Machines- &#8220;To implement infrastructure as code for your Azure solutions, use Azure Resource Manager templates (ARM templates). The template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[13,3],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts\/645"}],"collection":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=645"}],"version-history":[{"count":1,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts\/645\/revisions"}],"predecessor-version":[{"id":646,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=\/wp\/v2\/posts\/645\/revisions\/646"}],"wp:attachment":[{"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spktechfit.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}