For

Deploy and Configure Azure Resources with ARM Templates In this lab we will use Azure Resource Manager templates from different sources and with different deployment options, to deploy and configure virtual machines and infrastructure to Azure. DevOps MPP Course Source. This lab is used in course - Module 3.

Pre-requisites:. Complete the Module 1 lab. This is required for Task 4 in this lab. Visual Studio Community Edition, free from is required to be able to complete Task 6 Lab Tasks:. Deploy a ‘QuickStart’ ARM Template from GitHub. Generate an ARM template based on an existing resource group via the Portal.

Deploy a template using Powershell that removes all resources in a resource group. Edit and Deploy template via the Azure Portal. Deploy ARM Templates using Azure CLI 2.0. Create and Deploy an ARM template using Visual Studio Estimated Lab Time:. approx.

80 minutes Task 1: Deploy a ‘QuickStart’ ARM Template from GitHub. Go to. Scroll through the template options that are available, and briefly read some of the opening details in the README.md. You can select any template for this exercise, but we’ll choose 101-vm-simple-linux,. Once in the location click on Deploy to Azure. Once signed into your Azure subscription, fill in the Deploy a simple Linux VM pane details as follows:. Subscription:.

Resource group:. Location:.

Admin Username: adminuser. Admin password: Passw0rd01234. Dns Label Prefix:. Check the box to agree to the terms and conditions and click Purchase. Open the resource group and in the.Overview wait until the Deployments goes from Deploying to Succeeded. It will take a few minutes. You can verify the deployment by connecting to the VM by opening the VM, clicking Connect and copying the ssh command listed i.e.

Ssh adminuser@40.71.181.28. Connect to the Linux VM, on a windows OS you can use PuTTY or Bash on Ubuntu on Windows. If you have any problems logging in, you can reset the password in the VM pane on SUPPORT + TROUBLESHOOTING Reset password, and try again logging on again, you could also setit up to use ssh keys, a public/private key pair. Quick start templates from github can be used to get up and running quickly. They can also be used as starter templates and customised to suit your needs.

They are especially useful in more complex deployment scenarios, such as Azure Container Service (ACS), SharePoint Server Farms etc and have numerous Windows and Linux deployment scenarios and options available. You can also download the templates once they are imported into Azure and saved locally for future use.

Task 2: Generate an ARM template based on an existing resource group via the Portal. From the Azure portal, navigate to the rg1 resource group, or whatever name you called the resource group generated in the Module 1 lab that contains your deployed resources, such as VMs, LB, PIP etc i.e.

Not the resource group containing you Automation account and assets. Note: All resources in the resource group will be deleted, so ensure you have the correct resource group. It should contain the resources as in the screenshot below. Also, if you do not have the the deployed resources avaliable from Module 1 and do not have the time to go back and perform that lab now but wish to continue. On the resource group blade, click Automation script. This will generate a template containing definition of all resources contained within the resource group. On the Template tab, click on Parameters, and scroll down through the items in the viewing pane also.

Likewise, do the same for the Variables and Resources sections. This is just to get a feel for the structure and content. Scroll through the remaining tabs i.e. Parameters, CLI, PowerShell,.NET and Ruby. Click Add to library and enter a valid value for Name and Description and click Save. Click Add to library, use the following details.

Name: resource group name-ARMTemplate i.e. Rg1-ARMTemplate. Description: rg1-ARMTemplate and click Save. This will store the template within your Azure subscription. View the template in the Azure Portal by going to More Services and typing Templates in the search box and opening the template Task 3: Deploy a template using Powershell that removes all resources in a resource group. You can deploy an ARM Template a number of different ways, some of which are.

PowerShell -. Azure CLI -. REST APIs - We will deploy via a couple of those methods in this lab but you can view the references above for more details or options we do not cover in this lab. On your local machines, create the following Azure Resource Manager template and save it as EmptyTemplate.json. Note: Alternatively you can copy a version of the Emptytemplate.json file from github at and use that instead of creating the.json file yourself. Also, available in this GitHub location is the file Task2PowerShellcommands.ps1 which contains the powershell commands which are run in this lab task, steps 2 to 7. You can download this file locally, open it in the PowerShell ISE, highlight the individually commands as needed and hit F8 to run them one at a time, modifying them if needed to specify your local folder locations.

Arm Templates For Multiple Environment

#If you placed the folder in 'mydocuments', or some other system defined location, you can run the below command $template = environment::getfolderpath (“mydocuments” ) + ' EmptyTemplate.json' #otherwise you can just use the full path and define the variable that way, as below $template = 'C: Labfiles Devops200.2x-InfrastructureasCode Mod03' + ' EmptyTemplate.json'. From Windows PowerShell, deploy the template to the rg1 resource group, or whatever your resource group is called, by running the command below. 'dependsOn': This needs to be done as runbook has defined dependencies from when it was run. If you do not remove the dependsOn values, you will receive errors stating there are.Circular Dependancies. When you go to run the template, i.e.

Arm Template Format

Resources need to be available before another resource can be created. Click Save. Back on the Custom deployment blade, use the following settings:. Resource group = rg1 (or whatever you called your resource group earlier),. virtualmachinesvm1adminpassword = Pa55w.rd1234 (this value should already be populated now if you edited as above). virtualmachinesvm1adminpassword = Pa55w.rd1234 (this value should already be populated now if you edited as above) and click I agree to the terms and conditions stated above, and click Purchase. If you do receive errors, try work through them one by one, editing, saving and re-running.

Wait for the deployment to complete. Once the deployment completes, to apply the DSC configuration, you could use Azure Automation, just as you did in the second lab of this course. Alternatively, you could use Azure VM DSC extension on the VMs you are deploying to automatically set them up as Azure Automation DSC-managed nodes, which will apply the DSC configuration automatically. Task 5: Deploy ARM Templates using Azure CLI 2.0 In this task we will deploy a Template using two different scenarios with Azure CLI 2.0.

Scenario 1: using remote source. Scenario 2: from local source using separate parameters file. Scenario 1: Deploy a Template for Azure CLI 2.0 using remote source. Parameters ' ' adminUsername ': you will receive an error. Scenario 2: Deploy a Template for Azure CLI from local source using separate parameters file.

Az group deployment create -resource-group rg5 -template-file azuredeploy.json -parameters azuredeploy.parameters.json. Verify that the deployment was successful. Further details about the Azure CLI deployment are available in the help file, available by running the command az group deployment create –help, and also here Task 6: Create and Deploy an ARM template using Visual Studio. For this exercise, you will need Visual Studio 2017. You can download Visual Studio Community Edition free from. On your local machine, once Visual Studio 2017 is installed and available, launch Visual Studio 2017.

From the File menu, click New Project. In the New Project dialog box, navigate to Templates Visual C# Cloud and click Azure Resource Group from the list of installed templates. Set the name of the project and solution to AzureResourceGroup1 and set the location to the Documents folder. Ensure that the checkbox Create directory for solution is enabled and click OK. In the Select Azure Template dialog box, click Windows Server Virtual Machines with Load Balancer and click OK. The template implements an internal load balancer (rather than an external one, which you implemented via Azure Automation earlier, however the purpose of this exercise is to simply illustrate the process of authoring and deploying a template by using Visual Studio.

In the Solution Explorer window, click LoadBalancedVirtualMachine.json. In the JSON Outline window, expand the Parameters section and click imageSKU. Modify the imageSKU section so it looks as follows.