Deploy Microsoft Azure IaaS resources using ARM templates
Objective
Scenario
Virtual Machines
- AZRCamp-Admin
- AZRCamp-Edge
- AZRCamp-DC
- AZRCamp-Sync
Exercise 1 : Azure Subscriptions
This IT Camp lab requires a valid Azure subscription. While you may use an existing subscription such as a
subscription associated MSDN account or existing corporate account, it is strongly recommended to use a
an Azure Free Trial account or an Azure Pass. By using a Free Trial or an Azure Pass, you will avoid any
charges against your MSDN or corporate subscription that would result from doing the exercises in this
camp.
Your instructor may be able to provide you with a code that will allow you to redeem an Azure Pass. Or,
you may use a CLEAN and UNUSED Azure Trial account.
subscription associated MSDN account or existing corporate account, it is strongly recommended to use a
an Azure Free Trial account or an Azure Pass. By using a Free Trial or an Azure Pass, you will avoid any
charges against your MSDN or corporate subscription that would result from doing the exercises in this
camp.
Your instructor may be able to provide you with a code that will allow you to redeem an Azure Pass. Or,
you may use a CLEAN and UNUSED Azure Trial account.
- Create a Free Trial AccountNavigate to www.live.com and click Sign up now.
- Follow the on-screen instructionsFollow the on-screen instructions to create a new Microsoft Account.
- Navigate to www.azure.com and click Free TrialNavigate to www.azure.com and click Free Trial.
- Follow the on-screen instructionsFollow the on-screen instructions to activate a new Windows Azure Trial.
- Navigate to Manage.windowsazure.com and sign inNavigate to Manage.windowsazure.com and sign in.
- In Microsoft Azure portalIn Microsoft Azure portal, in the upper left, click your user name, and then click View my bill.
- Click your current trial subscriptionClick your current trial subscription, and then click Edit subscription details.
- Type a name you will recognizeType a name you will recognize in SUBSCRIPTION NAME, such as ITCamps, and then click the
Done icon.
Click Continue to advance to the next exercise.
Exercise 2 : Configure an Azure Pass
Your instructor may be able to provide you with a pre-provisioned Microsoft Account that already has an
Azure Pass subscription associated with it. Alternatively, your instructor may be able to provide you with
an Azure promotional code.
Azure Pass subscription associated with it. Alternatively, your instructor may be able to provide you with
an Azure promotional code.
- If you are not using the lab virtual machineIf you are not using the lab virtual machine to activate your Azure Pass promotional code, ensure
you open an InPrivate browser session before performing these steps.It is critically important that you do not accidently associate the promotional code with any account that has previously been associated with or linked to an Azure subscription. Use an InPrivate browser session to ensure that no credentials are unintentionally forwarded during the process to activate and
redeem the promotional code. If you fail to activate the code because you logged in with the wrong account, you will render the code useless and will not be able to use it again. - Navigate to www.live.com and click Sign up nowNavigate to www.live.com and click Sign up now.
- Follow the on-screen instructionsFollow the on-screen instructions to create a new Microsoft Account.Please ensure, you create an outlook.com, live.com or Hotmail.com account. Do not use accounts that have country code suffixes, such as .dk, ca, uk, etc. in their names.
- Navigate to http://www.microsoftazurepass.comNavigate to http://www.microsoftazurepass.com and follow the onscreen instructions to redeem
the promotional code.Once you have submitted the promotional code, it will take a few minutes for the account to become activated. Only one promo code can be redeemed per the life of the Microsoft ID. - Follow the on-screen instructions to activateFollow the on-screen instructions to activate a new Windows Azure Trial.
- Navigate to Manage.windowsazure.com and sign inNavigate to Manage.windowsazure.com and sign in.
- In Microsoft Azure portalIn Microsoft Azure portal, in the upper left, click your user name, and then click View my bill.
- Click your current trial subscriptionClick your current trial subscription, and then click Edit subscription details.
- Type a name you will recognizeType a name you will recognize in SUBSCRIPTION NAME, such as ITCamps, and then click the
Done icon.
Click Continue to advance to the next exercise.
Exercise 3 : Prepare the Azure Infrastructure
In this exercise, you will use the Lab01Start.ps1 script to log on to your Azure subscription and create an
Azure resource group that you will use for the remaining lab exercises. The script will also determine a
globally unique name that you can use to create a storage account in subsequent lab exercises.
Azure resource group that you will use for the remaining lab exercises. The script will also determine a
globally unique name that you can use to create a storage account in subsequent lab exercises.
- Run the Lab01Start.ps1 scriptPerform the following tasks on AZRCAMP-ADMIN:
Open File Explorer and navigate to C:\LabFiles\AZRITPROCamp\Lab01-Deploy Azure resources using templates. You may also download files used for this lab from the GitHub repository for the course at https://github.com/AZITCAMP/Labfiles.To perform the subsequent lab exercises, you need to create an Azure Resource Group and determine a globally unique name you can use to create a storage account. - Right-click Lab01Start.ps1, and click EditRight-click Lab01Start.ps1, and click Edit. The Windows PowerShell ISE console opens.
- In Windows PowerShell ISEIn Windows PowerShell ISE, on the upper Ribbon, click Run Script (green arrow).
- When prompted, enter a lower-case stringWhen prompted, enter a lower-case string that represents your initial, and press ENTER. The storage account name must contain only lower case letters and numbers and must be globally unique.
- In the Sign in to Windows Azure PowerShell dialogIn the Sign in to Windows Azure PowerShell dialog box, enter the email address of the account associated with your Azure subscription, and click Continue.
- On the sign in page, enter your passwordOn the sign in page, enter your password, and click Sign in. The script starts running and then pauses to display a name verified as unique for use a storage account name.
- Record the unique storage account nameRecord the unique storage account name, and press ENTER to continue. You will need to know the unique name for the storage account in a subsequent lab exercise.
- Leave the Windows PowerShell ISE console openLeave the Windows PowerShell ISE console open for subsequent lab exercises.
Click Continue to advance to the next exercise.
Exercise 4 : Understand Azure Quickstart templates
JSON templates simply provide a different way of defining the same types of resources that you may be
familiar with using the classic Azure model. For example, to create a new VM using the Azure Service
Management mode, you would specify the image name, the virtual machine name, the size, the
administrative account, the password credential, and other values. When deploying resources using JSON
templates, you specify the same information, but in a different format.
It is rarely necessary to create a JSON template from scratch. Microsoft maintains a large and growing
library of community contributed Azure templates on GitHub that you can leverage to learn about JSON
templates and to deploy your own applications.
In this task, you will view the quickstart templates that are available on GitHub and examine one of them
in depth.
familiar with using the classic Azure model. For example, to create a new VM using the Azure Service
Management mode, you would specify the image name, the virtual machine name, the size, the
administrative account, the password credential, and other values. When deploying resources using JSON
templates, you specify the same information, but in a different format.
It is rarely necessary to create a JSON template from scratch. Microsoft maintains a large and growing
library of community contributed Azure templates on GitHub that you can leverage to learn about JSON
templates and to deploy your own applications.
In this task, you will view the quickstart templates that are available on GitHub and examine one of them
in depth.
- Navigate toOpen Microsoft Edge (or Internet Explorer) and navigate to https://github.com/Azure/azure-quickstart-
templates.Perform the following tasks on AZRCAMP-ADMIN logged on as Contoso\Administrator using Passw0rd! as the password:GitHub is a repository service, based on Git that provides source control management (SCM) and revision control. GitHub expands on the functionality of the command-line based Git by providing a GUI
and collaboration features. - On the Azure Quickstart Templates pageOn the Azure Quickstart Templates page, spend a few moments examining the titles and scroll
down the page - Templates that have a prefix of 101Templates that have a prefix of 101 are simple templates; templates that have a prefix of 201 are
more advanced and complex templates. A searchable index of the quickstart templates is available at https://azure.microsoft.com/enus/documentation/templates. - Scroll down the pageScroll down the page, locate, and then double-click 101-vm-simple-windows.
Note that the folder contains 4 files: 1) The README.md is an html file that contains the description and
the button that you can click to deploy the template to an Azure subscription, 2) the azuredeploy.json
file is the main file used to deploy the cloud resources, 3) the azuredeploy.parameters.json is the file
where you can provide values for the parameters defined in the azuredeploy.json file and pass them in
at execution time, and 4) the metadata.json file provides additional data about the deploy template.
- Click azuredeploy.jsonClick azuredeploy.json.
- The JSON file opens as shown belowThe JSON file opens as shown below:
Please click on the camera icon on the lower left hand side to view the screenshot.A JSON file is constructed of key/value pairs. For example, in the image above, “ContentVersion" is thekey and "1.0.0.0" is the value. A key is always a string enclosed in quotation marks. A value can be a string, securestring, number, boolean expression, array, or object. A JSON object is enclosed in curly braces, "{ }". In a key/value pair the key is always followed by a colon. Key/pairs are separated by commas.
A JSON template may also contain functions and expressions. Expression are enclosed in square
brackets, “[ ]', and can appear anywhere in a JSON string. Functions calls have the format functionName(arg1,arg2,arg3). Properties are referenced using the dot and index operators.
A JSON template may have as many as six sections: 1) $schema (a required element that provides the
location of the file that describes the version of the template language, 2) (a required element that
provides the version of the template), 3) parameters (an optional element that defines values that are passed in when the template is executed), 4) variables (an optional element that defines the values that are used when template is executed), 5) resources (a required element that defines the resources that are deployed or updated in a resource group), and 6) outputs (an option element that defines values that are returned after a deployment.) - At the top of the fileAt the top of the file, note the first line that references a JSON schema. The schema reference is used by intelligent JSON clients to determine the schema that is applicable to the JSON file and to provide additional functionality such as autocomplete and intellisense.
- Note the Parameters keyNote the Parameters key.The value for the Parameters key is an array of parameter objects that represent the dynamic input for the JSON template. Each of the parameter objects has a name that is used to pass values in at runtime and is referenced within the JSON itself in other sections. For example, "NewStorageAccount" is the name of the parameter that is supplied as an input and used to provide the name of the storage account resource specified in the JSON file.
- In the parameters sectionIn the parameters section, note the "adminPassword" parameter, and note that the "type" value.Each parameter has a type, such as string, securestring, number, etc. Securestring is a special data type that is used to ensure that the value is not persisted anywhere in the Azure platform. This ensures that sensitive information such as passwords are not displayed.
- Scroll down to view the WindowsOSVersionScroll down to view the WindowsOSVersion parameter object.Note that a parameter can include a default value. When you execute the JSON template, you will be prompted for any parameter values that are missing from the input, unless you have specified a default value. Note also that a parameter can include an array of allowed values, which is useful if you want to constrain the input to a set of specific values, for example specific regions, etc. Finally, note the metadata key, where you can include a description of the parameter.
- Scroll down to the variables sectionScroll down to the variables section that begins at around line 42.Variables, in general, represent static values that are already present in the template, in contrast to parameter values which are passed in at execution time. Variables can also be used to simplify template language expression by using expression and functions, such as "[resourceId…]" and "[concat…]", as highlighted above. In the case of the concat function, variables can be composed of other variables or parameter values that are input at run time. ResourceId is a helper function that is used to get unique IDs of resources.
- Scroll down to the resources sectionScroll down to the resources section that begins at around line 61.In the resources array section, you define the resources that you wish to deploy or update. Each resource must include a type, name, and apiVersion. The type value is the namespace of the resource provider and the supported resource type. The value for the type is a substring of the URL you would use if you wanted to create a resources, such as a storage account, against the Azure REST (representational state transfer) API (application programming interface). When the template is deployed, the template engine makes the same HTTP put calls that would be made if you were directly interacting with the API.
If you wish to find out the values and the properties associated with a resource, you can find the documentation on the Azure REST APIs here: https://msdn.microsoft.com/enus/library/azure/mt420159.aspx. For example, to find out more information about the Microsoft.Storage/storageaccounts resource, you can consult the Azure Storage Provider REST API reference at https://msdn.microsoft.com/en-us/library/azure/mt163683.aspx.
Optional key/value pairs for resource objects include location (where you define the geo-location for the resource), properties (where you define resource-specific settings), tags (that provide metadata associated with resource), resources (child resources that depend on the resource being defined), and dependsOn (resources that the resource being defined depends on). - Scroll down to the beginning of the VMScroll down to the beginning of the virtual machine resource definition, which begins at around line 131.Note the "dependsOn" key/value pair. Before the virtual machine can be created, the storage account and the network interface, which in turn has dependencies of its own (see lines 105 -111), must exist. The script is evaluated for dependencies to create objects in the appropriate order. If no dependencies are specified, Azure Resource Manager attempts to create them in parallel. This can result in much faster deployments for large and complex infrastructures over the Azure Service Manager mode.
- In the Microsoft Edge BrowserIn the Microsoft Edge Browser, click back to return to the previous page.
- On the 101-simple-windows-vm pageOn the 101-simple-windows-vm page, click Deploy to Azure.
- On the Microsoft Azure sign in pageOn the Microsoft Azure sign in page, enter the email address and password associated with your subscription, and sign in. The Azure Portal opens showing the Custom deployment and Parameters blades.
Note that the Parameters blade provides fields for text input. In the case of the WINDOWSOSVERSION parameter, note the presence of a default value and a drop-list of allowed values. - On the Custom deployment bladeOn the Custom deployment blade, click Edit template. You can edit the template before deploying it, for example, to change variable names or modify resources that the template describes for deployment.
- Close the Edit template bladeClose the Edit template blade.
- In the Custom deployment bladeIn the Custom deployment blade, in Resource group, click Use Existing Or create new.
- In the Create a new resource group text boxIn the Create a new resource group text box, type test.
- Click Resource group locationClick Resource group location.
Note that once you enter a name for a new resource group, you can also specify a location. - Review the locationsReview the locations, and the close the Location blade.
- Close the Custom deployment bladeClose the Custom deployment blade. You are not going to deploy the template at this time. Rather, you will modify the template in a subsequent task and then explore other ways of deploying the template.
- If prompted by a warningIf prompted by a warning indicating your unsaved edits will be discarded, click OK.
- Leave the Azure Portal openLeave the Azure Portal open for a subsequent lab exercise.
Click Continue to advance to the next exercise.
Exercise 5 : Configure Git repository and Visual Studio Code (Optional)
As you saw in the previous exercises, GitHub is used to store ARM templates and other code-related
objects. GitHub is a web-based Git repository to ensure availability and provide a version control system
for files.
Version control systems record changes to files or a set of files so that they can retrieved at a later time.
There are different kinds of version control systems, the simplest being the manual use of multiple folders
to store different versions of your files.
More sophisticated and fault tolerant version control systems use central or distributed databases to
store the files and their changes.
Git is a distributed version control system in which clients clone entire repositories to ensure that there is
no single point of failure. If a particular repository fails, the contents can be restored from a cloned copy
that exist elsewhere.
In this exercise, you will learn more about GitHub and Git repositories. You will also learn how to configure
Visual Studio Code to use Git.
objects. GitHub is a web-based Git repository to ensure availability and provide a version control system
for files.
Version control systems record changes to files or a set of files so that they can retrieved at a later time.
There are different kinds of version control systems, the simplest being the manual use of multiple folders
to store different versions of your files.
More sophisticated and fault tolerant version control systems use central or distributed databases to
store the files and their changes.
Git is a distributed version control system in which clients clone entire repositories to ensure that there is
no single point of failure. If a particular repository fails, the contents can be restored from a cloned copy
that exist elsewhere.
In this exercise, you will learn more about GitHub and Git repositories. You will also learn how to configure
Visual Studio Code to use Git.
- Create GitHub account and public repositoryPerform the following tasks on AZRCAMP-ADMIN logged on as Contoso\Administrator using Passw0rd! as the password: On AZRCAMP-ADMIN, open Microsoft Edge.The remaining lab exercises require that you have a GitHub account and repository named Templates.
In this task, you create a GitHub account and then configure a public repository named Templates.
This lab exercise is optional if you already have a GitHub account.
Note that, if you do have a GitHub account and you have enabled 2-factor authentication for it, you may have difficulties authenticating to your account when using Visual Studio Code. If you have 2-factor authentication enabled on your Git repository, consider creating a Git account for this lab. - Navigate to https://github.comNavigate to https://github.com
- On the home page, click Sign upOn the home page, click Sign up.
- On Join GitHub pageOn Join GitHub page, enter a username, email address, and password. Please note that when you perform certain operations on GitHub, such as commits, your email address is publically viewable. For more information, please see https://help.github.com/articles/keepingyour-email-address-private/.
- Click Create an accountClick Create an account.
- On the Welcome to GitHub pageOn the Welcome to GitHub page, click Finish sign up.
- On the GitHub Bootcamp pageOn the GitHub Bootcamp page, click Create a repository.
- Open your email clientOpen your email client and open the verification email sent to you by the GitHub web site.
- Click Verify email addressClick Verify email address.
- Switch to the GitHub pageSwitch to the GitHub page.
- Click Create a repositoryClick Create a repository (alternatively, in the upper right corner, click +, and then click New
repository). - In Repository name, type TemplatesIn Repository name, type Templates, select Initialize this repository with a README, and then
click Create repository. You will clone the repository in the next task. - Leave the Microsoft Edge browser openLeave the Microsoft Edge browser open for the next task.
Click Continue to advance to the next exercise.
Exercise 6 : Configure GitHub desktop and clone repository
In this task, you will launch GitHub, configure settings for the application, and then clone the Templates
repository you configured
repository you configured
- Switch to the desktop of the AZRCAMP-ADMINSwitch to the desktop of the AZRCAMP-ADMINPerform the following tasks on AZRCAMP-ADMIN logged on as Contoso\Administrator using Passw0rd! as the password:
- On the desktop, double-click GitHubOn the desktop, double-click GitHub. The GitHub desktop application was installed as part of the lab setup.
- On the Welcome pageOn the Welcome page enter your GitHub username and password, and the click Log in.
- Click ContinueClick Continue.
- Under No local repositories found, click dashboardUnder No local repositories found, click dashboard. The GitHub desktop application opens showing a pre-configured Git repository named Tutorial that contains a .gitattributes and .gitignore files. Before proceeding with the next steps, feel free to launch the tutorial by clicking Got it!. Otherwise, close the tutorial.
- In the upper right cornerIn the upper right corner, click Settings (the gear icon).
- Click Options.Click Options.
- On the Options pageOn the Options page, in Clone path, enter C:\GitHub, and then click Save.
- On the GitHub home pageOn the GitHub home page, in the upper left corner, click Add (plus sign).
- Click CloneClick Clone.
- Click TemplatesClick Templates, and then click Clone Templates., and then click Clone Templates.
- In the Browse for Folder dialog boxIn the Browse for Folder dialog box, ensure that C:\GitHub is selected, and then click OK. If you receive an error, ensure that the Tutorial repository is closed/removed and perform step 12 again.
- On the desktop, double-click Git-ShellOn the desktop, double-click Git-Shell. A PowerShell window opens. The option to integrate the Git commands with PowerShell is configured in the GitHub client.
- At the PowerShell promptAt the PowerShell prompt, type the following command and press ENTER.
↪ Git config --global credential.helper wincred
This command is necessary to ensure that Visual Studio code can authenticate against the GitHub web site. The command is case-sensitive. - At the PowerShell promptAt the PowerShell prompt, type the following command and press ENTER.
↪ Git config --list
This command shows the settings that are configured for Git. Note the bottom of the output displays
your GitHub user name and email address. These settings were configured when you logged into the
GitHub Windows client. Normally, you would configure Git using commands from a shell, such as Bit
Lab created by HynesITe, Inc. For questions or comments, send an email message to content@hynesite.biz Page | 26
Bash or the integrated PowerShell prompt you see in the lab. For more information on configuring and
using Git, please see http://git-scm.com/doc. - Open File ExplorerOpen File Explorer, and browse to C:\LabFiles\AZITPROCamp\Lab01-Deploy Azure resources
using templates. - Select and right-click 101-simple-windows-vmSelect and right-click 101-simple-windows-vm, and then click Copy. For your convenience, the Azure Quickstart template you examined in the previous exercise was previously downloaded as part of the lab set up.
- In File ExplorerIn File Explorer, navigate to C:\GitHub\Templates.
- Press CTRL-VPress CTRL-V to paste the folder to C:\GitHub\Templates.
- In File Explorer, on the RibbonIn File Explorer, on the Ribbon, click View, and then select Hidden items. The hidden .git folder appears. This folder is created upon initialization of Git repository. The .git folder includes Git database and other files necessary for staging and committing changes to files for source version control.
- Close File ExplorerClose File Explorer.
Click Continue to advance to the next exercise.
Exercise 7 : Examine Visual Studio Code integration with Git and push commits to remote repository
Visual Studio Code has integrated support for the most common Git commands, for example, to stage
and commit changes.
In this task, you will see a demonstration of Visual Studio Code integration with Git and push commits
(changes you wish to be permanent) to the remote repository on GitHub.
and commit changes.
In this task, you will see a demonstration of Visual Studio Code integration with Git and push commits
(changes you wish to be permanent) to the remote repository on GitHub.
- Open Visual Studio CodeOn the Desktop or from the taskbar, open Visual Studio Code.Perform the following tasks on AZRCAMP-ADMIN logged on as Contoso\Administrator using assw0rd! as the password:
- If you see a messageIf you see a message indicating that you need to install Visual Studio Code, please ignore the
message (or click Later) and complete the steps below. - In Visual Studio CodeIn Visual Studio Code, click File, and click Open Folder.
- In the Select Folder dialog boxIn the Select Folder dialog box, navigate to C:\GitHub, click Templates, and then click Select
Folder.
The folder opens and Visual Studio Code provides a visual indication that Git detects uncommitted files in the folder. These are the files you copied to the folder earlier. You may have to close and reopen the folder to see the uncommitted indication as per the screen shot below. To close the folder, click File, and then click Close Folder.
- Click the Git icon on the leftClick the Git icon on the left.
- Press the CTRL key down, and select both filesPress the CTRL key down, and select both files.
- Click the ellipsisClick the ellipsis, and then click Commit All.Git files have three states: modified, staged, and committed. Modified means that the files are in a workspace and have been changed but have not yet been committed to the database in the repository. Staged means the files have been moved to a staging area prior to being committed, for example, as a holding area pending review. Committed means that a snapshot of the file is committed to the database.
- In Message, type Initial VersionIn Message, type Initial Version, and press CTRL+ENTER.
These files will represent a starting point for changes you will make in a subsequent exercise. The changes are committed to the local repository. The files disappear from view in the Git node. In the next step, you will push the committed files to the remote repository. - Click the ellipses, and then click PushClick the ellipses, and then click Push.
- When prompted by Visual Studio Code dialog boxWhen prompted by Visual Studio Code dialog box, enter your Git username and password, and click OK.
The authentication fails. This is expected. - When prompted with an error messageWhen prompted with an error message indicating that Authentication failed on the git remote,
click Close. - Open File ExplorerOpen File Explorer, and browse to C:\LabFiles\Utils and double-click git-credentialwinstore.exe.
- When prompted, click YesWhen prompted, click Yes.
This small executable downloaded from Codeplex.com resolves an issue with authentication to GitHub
using VSCode. If you have enabled multi-factor authentication on your GitHub repository, this workaround may not be effective. - Switch to Visual Studio CodeSwitch to Visual Studio Code, click the ellipses, and then click Push.
- When prompted by the Git Credentials dialog boxWhen prompted by the Git Credentials dialog box, enter your Git username and password, and
click OK. The committed files in the local repository are pushed to the repository on GitHub. - Leave Visual Studio Code openLeave Visual Studio Code open for subsequent lab steps, and switch to the instance of Microsoft
Edge that you left open in a previous task. - Ensure that you are viewing the Templates pageEnsure that you are viewing the Templates page for your repository, and then press F5 to refresh the page. You should see the 101-simple-windows-vm folder from your local repository.
- Click 101-simple-windows-vmClick 101-simple-windows-vm. You should see the two JSON files in the folder.
- Leave the browser openLeave the browser open for subsequent steps in the next exercise.
Click Continue to advance to the next exercise.
Exercise 8 : Modify and Deploy Azure Quickstart Templates
As you learned in the previous exercise, it is rarely necessary to construct a JSON-based Azure Resource Manager template from scratch. In many instances, you will be able to find a sample template to use as a starting point for your own template. A basic understanding of how templates are constructed, combined with an appropriate sample template to use as a starting point, will allow you to create your own custom templates with relative ease.
For additional information on authoring and modifying template files, please see Authoring Azure Resource Manager templates at https://azure.microsoft.com/en-us/documentation/articles/resourcegroup-authoring-templates/.
In this exercise, you will build on the understanding that you acquired in a previous exercise to customize a sample template and then deploy it.
For additional information on authoring and modifying template files, please see Authoring Azure Resource Manager templates at https://azure.microsoft.com/en-us/documentation/articles/resourcegroup-authoring-templates/.
In this exercise, you will build on the understanding that you acquired in a previous exercise to customize a sample template and then deploy it.
- If not already openIf not already open, open Visual Studio Code, and navigate to the C:\GitHub\Templates\101-simple-windows-vm folder.In a previous exercise, you examined the 101-simple-windows-vm template that is available on GitHub. You subsequently added this template to your own Git repository. In this task, you will customize this template and its related parameters JSON file using Visual Studio Code to meet your specific and additional requirements. Also, you will stage and commit your changes to the local and remote Git repository.
Perform the following tasks on AZRCAMP-ADMIN logged on as Contoso\Administrator using Passw0rd! as the password: - In the tree pane, click azuredeploy.jsonIn the tree pane, click azuredeploy.json
- Type the following code below line 28Type the following code below line 28.
Note that intellisense and autocomplete make the task of entering JSON easier. Recall the parameters are passed to the template at runtime and allow users the ability to specify values. In this case, you are creating a default value and restricting choice to locations where Premium storage is available. For a list of datacenters showing the services offered by each, please see http://azure.microsoft.com/en-us/regions/#services. - Scroll down to the variables sectionScroll down to the variables section, and delete the "location": "West US" key/value pair.
- Click Edit and then click Replace.Click Edit and then click Replace.
- In Find, type variables('location')In Find, type variables('location'); in Replace, type parameters('location'), and then click Replace All, as shown below.
- Scroll to the end of the parameters sectionScroll to the end of the parameters section and the start of the variables section.
- At the end ofAt the end of the second-last closing brace before the variables section, add a comma, as shown below.
- Add the following lines of codeThen, add the following lines of code to create a parameter for size of the data disk.
Tip: You can find the completed solution in the C:\LabFiles\AZIT{ROCamp\Solutions folder. If you like, you can copy and paste code from the solution into your JSON script. - Scroll to the end of the variables sectionScroll to the end of the variables section, and add a comma at the end of the subnetRef key/value pair:
- Then, type the followingThen, type the following on a single line at the end of the variables section:
↪ "dataDisk1VhdName":
"[concat('http://',parameters('newStorageAccountName'),'.blob.core.w
indows.net/',variables('vmStorageAccountContainerName'),'/',variable
s('vmName'),'dataDisk1.vhd')]"
You can find the completed solution in the C:\LabFiles\AITPROCamp\Solutions folder. - Scroll down to the resources sectionScroll down to the resources section and locate "osDisk" section.
- Between the "osDisk" and "networkProfile" sectionBetween the "osDisk" and "networkProfile" section, add the following resource:
Please click on the camera icon on the lower left hand side to view the screenshot.Be very careful where you place this code section. Before proceeding to the next step, scroll to the end of the file and double-check for any red squiggles that might indicate improper placement of this snippet. - Click File and then click SaveClick File and then click Save.
- Click the Git icon on the leftClick the Git icon on the left.
- Under CHANGES, click azuredeploy.jsonUnder CHANGES, click azuredeploy.json. Two screens appear. The left screen shows the original file; the right screen shows the changes.
- Review your changes, right-click azuredeploy.jsonReview your changes, right-click azuredeploy.json, and then click Stage.
- On the left, click the Explore iconOn the left, click the Explore icon.
- Click azuredeploy.parameters.jsonClick azuredeploy.parameters.json.
- In azuredeploy.parameters.jsonIn azuredeploy.parameters.json, add key/value pairs for the location, WindowsOSVersion, and sizeOfDiskInGB parameters and provide unique names for the storage account and DNS name, as follows:
Please click on the camera icon on the lower left hand side to view the screenshot. - Save the azuredeploy.parameter.json fileSave the azuredeploy.parameter.json file.
- Click the Git icon in the navigation paneClick the Git icon in the navigation pane, right-click azuredeploy.parameters.json, and click Stage.
- Click the ellipses, and the click Commit StagedClick the ellipses, and the click Commit Staged.
- In the Message box, type Update1In the Message box, type Update1, and press CTRL+ENTER. A snapshot of the files is now committed to the local repository.
- Click the ellipses, and then click PushClick the ellipses, and then click Push.
Note that you are not prompted for credentials. You configured credential caching earlier with the
git config --global credential.helper wincred command. - Switch to the Microsoft Edge browserSwitch to the Microsoft Edge browser you left open in the previous exercise and press F5 to
refresh the page. You should see that the two JSON files have been pushed to the remote repository. - Leave the browser open for the next taskLeave the browser open for the next task.
Click Continue to advance to the next exercise.
Exercise 9 : Deploy custom JSON files
In the previous task, you modified the sample JSON to meet specific requirements and subsequently committed your changes to both a local and remote Git repository. In this task, you will examine deploying the custom template using the Azure portal and Windows PowerShell.
- If not already openIf not already open, open Visual Studio Code, and navigate to the C:\GitHub\Templates\101-simple-windows-vm folder.Perform the following tasks on AZRCAMP-ADMIN logged on as Contoso\Administrator using Passw0rd! as the password:
- In the tree pane, click azuredeploy.jsonIn the tree pane, click azuredeploy.json.
- Click anywhere in the details paneClick anywhere in the details pane, press CTRL+A and then press CTRL+C to copy the contents of
the file to the clipboard. - Switch to Microsoft EdgeSwitch to Microsoft Edge.
- Open a new tabIf not already logged on to the Microsoft Azure portal, open a new tab, navigate to
https://portal.azure.com, and log on the account you are using for your Azure subscription. - In the Microsoft Azure portalIn the Microsoft Azure portal, in the navigation pane, click New.
- In the New blade, click MarketplaceIn the New blade, click Marketplace
- In Search everything text boxIn Search everything text box, type Template, click Template deployment from the drop-down list, and press ENTER.
- Double-click Template deployment in the resultsDouble-click Template deployment in the results.
- In the Template deployment blade, click Create.In the Template deployment blade, click Create.
- The Custom deployment blade appearsThe Custom deployment blade appears.
- In the Custom deployment bladeIn the Custom deployment blade, click Edit template.
- In the Edit template bladeIn the Edit template blade, delete all the lines of JSON script.
- Place the cursor in the template areaPlace the cursor in the template area, and press CTRL+V to paste the JSON script that you copied to the clipboard earlier.
- Click SaveClick Save.
- Click Edit parametersClick Edit parameters.
The Parameters blade should appear immediately. If it does not, this means that there is something wrong with your JSON script, most likely a mismatch between opening and closing braces or brackets.
If the template has the proper formatting, you will see small green rectangle in the upper right side of the template; otherwise, you will see small red squares on the right side that provide an approximate location of the source of the problem. - In the parameters bladeIn the parameters blade, note the presence of the LOCATION (string) and SIZEOFDISKINGB (string) parameters that you added to the original JSON script.
- Close Parameters and the Custom deployment bladesClose the Parameters and the Custom deployment blades without creating the deployment. You are going to deploy your custom template using a PowerShell command in a later step. You examined how to deploy a custom template in the Azure portal as a demonstration and to do a final verification on your template.
- When prompted, click OK to discard unsaved editsWhen prompted, click OK to discard unsaved edits.
- Close all open bladesClose all open blades in the portal to return to the Start page.
- Leave Microsoft Edge open for subsequent stepsLeave Microsoft Edge open for subsequent steps.
- Switch to the Windows PowerShell ISE consoleSwitch to the Windows PowerShell ISE console you left open in a previous exercise. If you closed the console, please open it and run the C:\LabFiles\AZITPROCamp\Lab01..\Lab01Start.ps1 script again.
- In the command paneIn the command pane, type the following command on a single line, and press ENTER.
↪ New-AzureResourceGroupDeployment -DeploymentName "Simple-VM"
-ResourceGroupName RG-AZITCAMP -TemplateFile
"C:\GitHub\Templates\101-simple-windows-vm\azuredeploy.json”
You will be prompted for the storage account name, as shown below. If you do not wish to be prompted for required parameters, you can add a template parameter file to the command. You will do this in the next steps. However, you will use the version of the JSON scripts that are available in your remote repository. - In the PowerShell command paneIn the PowerShell command pane, press CTRL+C to break out of the command.
- Switch to Microsoft EdgeSwitch to Microsoft Edge.
- In the tab that displays the contentsIn the tab that displays the contents of your GitHub Templates repository, click azuredeploy.json.
- On the azuredeploy.json page, click RawOn the azuredeploy.json page, click Raw.
- Copy the URL displayed for the raw versionCopy the URL displayed for the raw version of the azuredeploy.json file to the value of the $templatefileURI on line 57 of the Lab01Start.ps1 script.
- Repeat steps 27 - 29 to copy the URLRepeat steps 27 - 29 to copy the URL for the azuredeploy.parameters.json file to the value for the $parameterfileURI variable on line 59 of the Lab01Start.ps1 script.
- The resulting section of the scriptThe resulting section of the script should look like something this:
Please click on the camera icon on the lower left hand side to view the screenshot. - Select the entire block of variablesSelect the entire block of variables and click Run Selection.
- Scroll to the bottom of the scriptScroll to the bottom of the script, and remove the # at the beginning of the second command to perform a resource group deployment.
- Select the entire lineSelect the entire line, and then click Run Selection. After a few minutes, the command should return a successful result. You can verify the results by viewing the new resources in the Azure portal.
- Please leave the Windows PowerShell ISE consolePlease leave the Windows PowerShell ISE console open for the next exercise.
Click Continue to advance to the next exercise.
Exercise 10 : Remove resource group used for lab
Because each lab in this series begins with an empty resource and because Azure resources are potentially billable, it is necessary to remove the resource group you created and used in this lab. Also, because Azure trial accounts are limited to 4 compute cores, it is important that you remove the resource group to ensure you do not run out of resources, if you have an Azure trial account.
- Remove Azure resource groupIf not already open, open Windows PowerShell ISE.In this task you will run a Windows PowerShell script to remove the resource group you created and used in this lab.
Perform the following tasks on AZRCAMP-ADMIN logged on as Contoso\Administrator using Passw0rd! as the password: - Click FileClick File, click Open, browse to C:\LabFiles\AZITPROCamp\Scripts, select RGCleanup.ps1, and click Open.
- On the menu, click RunOn the menu, click Run.
- When promptedWhen prompted, log into your Azure subscription.
- When prompted to delete RG-AZITCAMP-LAB01When prompted to delete RG-AZITCAMP-LAB01, click Yes.
- If you used a different resource group for the labIf you used a different resource group for the lab, you can modify the PowerShell script to delete that resource group.
Congratulations!
Click Continue to close and finalize this lab.
Click Continue to close and finalize this lab.
3 comments:
I got a good answer from the above description,but it still requires some more update to be made. Please share more content on Devops Online Course Bangalore
Thank you. Well it was a nice post and very helpful information on
Azure Online Training
It is really a great work and the way in which you are sharing the knowledge is excellent.
Microsoft Azure Online Training
Post a Comment