- Lab
- A Cloud Guru
Deploying Azure Templates with Visual Studio Code
In this lab, we use a Windows 2019 Server with Visual Studio Code to deploy an Azure QuickStart template. We have been asked to deploy a Ubuntu virtual machine for the developer team to test a new application. The developers have requested a standard B2S virtual machine with TCP ports 443 open to the internet both on inbound and outbound channels.
Path Info
Table of Contents
-
Challenge
Provision Visual Studio 2019 Community Virtual Machine
-
Click Home > + Create a resource.
-
Search for "Visual Studio 2019 Community (latest release) on Windows 2019 Server (x64)".
-
Click Create.
-
Select the provided Resource Group.
-
Enter Virtual machine name "VS-Studio-01".
-
For Region, select (US) West US.
-
For Availability Options, No infrastructure redundancy required.
-
For Azure Spot Instance, No.
-
For Size, Change Size, then select D3_v3.
-
For Administrator Account, enter "Admin1234567" without the quotes for Username and Password.
-
For Public inbound ports, Allow selected ports.
-
Select the inbound ports RDP (3389).
-
For Already have a Windows Server License?, select No.
-
Click Next: Disks.
-
Click Create and attach a new disk.
-
Accept the defaults and click OK.
-
Click Review and Create and then Create.
-
-
Challenge
Connect to Visual Studio Virtual Machine and Add Plugins
-
Connect to VS-Studio-01 via RDP. Log in with
Admin1234567
as the username and password. -
Open Visual Studio Code.
-
Open Marketplace and install Azure CLI Tools.
-
Install Azure Powershell Tools.
-
Open the following website and click Install: https://marketplace.visualstudio.com/items?itemName=msazurermtools.azurerm-vscode-tools
Note: All plugins are from Microsoft.
-
-
Challenge
Download and Modify "101-vm-simple-linux" Template from GitHub
-
Open the
101-vm-simple-linux
template from GitHub. -
Open raw view, then copy all.
-
In Visual Studio Code, create a new local JSON file in VS Code called
azuredeployment.json
. -
Paste the copied template contents into
azuredeployment.json
. -
Create a file
azuredeployment.parameters.json
. -
Paste the template parameters from the RAW view.
-
Save the parmeters file
azuredeployment.parameters.json
. -
Find line 27, make sure the following shows:
"defaultValue": "password",
-
Add a comma after the brackets underneath
securityRules
. -
Select all of the information under
securityRules
, including the brackets (but not the comma). Copy it and paste it on the line after the comma in the previous step. -
Change the following fields.
"name": "SSL",
"priority": 1001,
"destinationPortRange": "443"
-
Save the tenplate
azuredeployment.json
.
-
-
Challenge
Configure Azure Cloud Shell
Click the [>_] Icon on the blue Azure bar.
- Click PowerShell, then Show advanced settings.
- Change Cloud Shell Region to West US.
- Set Resource group to Use existing.
- Use build a unique Storage account and File share by using the following:
- lalab446mmddyyyy (use the 8-digit date or mmddyyyy, e.g.
la44601212020
)
- lalab446mmddyyyy (use the 8-digit date or mmddyyyy, e.g.
- Click Create Storage.
If successful, you should see something similar to:
Your cloud drive has been created in: Subscription Id: 4cedc5dd-e3ad-468d-bf66-32e31bdb9148 Resource group: 212-e743b5-deploying-azure-templates-with-cloud-shell-6gd Storage account: la44601212020 File share: la44601212020 Initializing your account for Cloud Shell... Requesting a Cloud Shell.Succeeded. Connecting terminal... Welcome to Azure Cloud Shell Type "az" to use Azure CLI Type "help" to learn about Cloud Shell linuxacademy@Azure:~$
-
Challenge
Configure Template Storage and Upload
Select the unique Storage account created with the following: lalab446mmddyyyy
- Under Settings in the left-hand menu, click Configuration.
- Set Allow Blob public access to Enabled.
- Under Blob service in the left-hand menu, click Containers.
- Click + Container to add a new container.
- Enter "templates" into the Name box.
- Set Public access level to Blob (anonymous read access for blobs only).
- Click Create.
- Double-click the templates folder.
- Upload both
azuredeployment
andazuredeployment.parameters
. - Double-click the link for azuredeployment.json.
- Copy the URL to the clipboard.
-
Challenge
Deploy Azure Template via Azure Cloud Shell
-
In the Cloud Shell window, run the following command:
Get-AzResourceGroup
This should return a response similar to the following:
PS Azure:\> Get-AzResourceGroup ResourceGroupName : 210-c1eed6-deploying-azure-templates-with-visual-studio-xti Location : westus Tags : ResourceId : /subscriptions/4cedc5dd-e3ad-468d-bf66-32e31bdb9148/resourceGroups/210-c1eed6-deploying-azure-templates-with-visual-studio-xti
-
Create the deployment. Remember to replace the
RESOURCE_GROUP_NAME
and theURL_COPIED_IN_THE_PREVIOUS_TASK
with the appropriate values.az group deployment create -g RESOURCE_GROUP_NAME --template-uri URL_COPIED_IN_THE_PREVIOUS_TASK
If successful, we will get a success message.
-
-
Challenge
Deployment Validation
- Once the deployment is complete, click All resources in the Azure portal.
- Click simpleLinuxVM.
- Under Settings, click Networking.
- Verify the existence of the SSL rule.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.