0% found this document useful (0 votes)
6 views

Azure Discovery Day Lab Guide

Uploaded by

ayobK
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Azure Discovery Day Lab Guide

Uploaded by

ayobK
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Azure Discovery Day

Hands-on Lab Guide


Azure

Contents
Objectives of lab tasks ................................................................................................................................................... 3
Pre-requisites .................................................................................................................................................................. 3
Task 1 – Creating an Azure Virtual Machine ............................................................................................................... 4
First look at Azure portal ........................................................................................................................................... 4
Creating a resource group......................................................................................................................................... 5
Creating a virtual machine with Azure Portal ......................................................................................................... 7
Logging in to virtual machine and setting up Visual Studio .............................................................................. 14
Task 2 – Creating a Linux virtual machine in Azure.................................................................................................. 16
Activating Azure PowerShell in Azure Portal ........................................................................................................ 16
Creating a Linux VM using PowerShell commands.............................................................................................. 17
Task 3 - Deploy a Linux Container in Azure Container Instances........................................................................... 22
Creating a Resource Group ..................................................................................................................................... 22
Configure Azure Container Instances .................................................................................................................... 23
Task 4 - Deploy a Windows Container in Azure Container Instances.................................................................... 28
........................................................................................................................................................................................ 30

Page 2 of 32
Azure

Objectives of lab tasks


Thank you for attending Azure Discovery Day. The objective of the afternoon lab is to introduce you to Azure
fundamentals through a hands-on experience. As your trainers, we hope you can walk away with newly
gained insights and confidence to start your Azure journey.

The lab is divided into 3 tasks.

Task 1 aims to get you familiar with how resources on Azure and Azure portal are organized and how to
access and create resources. At the end of task 1, you should have access to a functional virtual machine with
Visual Studio running on Azure.

Task 2 aims to broaden your options in creating Azure resources and managing scalable compute resources.
Issuing instructions through scripting tools such as PowerShell and Azure command line interface (CLI) is a
scalable way of automating the deployment of infrastructure. Task 2 introduces you to the concept of
infrastructure as code and how to create / manage a virtual machine scale set.

Task 3 & Task4 aims to show you a different way of deploying and managing your workloads through Azure
Container Instances (ACI). Azure Container Instances offers the fastest and simplest way to run a
container in Azure, without having to manage any virtual machines and without having to adopt a
higher-level service.

• Task 3 aims to introduce you to Docker Hub, the public registry where you can find Container Images
which can be easily deployed within Azure Container Instances without the need to setup or provision
underlying platform. The scenario demonstrates bringing up a Linux Container with a fully functioning
game on it.

• Task 4 aims to use Microsoft’s Container registry used to publish its official images. The scenario
demonstrates a Windows Nano Server with IIS on it.

Pre-requisites
To participate in the hands-on-lab, you need

1. An Azure subscription – you can sign up for a trial at azure.com/free


2. Modern PC running Windows 7 and above or macOS with fast internet access
3. Experience or understanding of managing IT infrastructure or DevOps on premise
4. A soft copy of this lab guide downloadable at aka.ms/addsg

Page 3 of 32
Azure

Task 1 – Creating an Azure Virtual Machine


In this exercise, we will login to the Azure portal and see how it is organized and how to access features and
workloads. After that, we will create a resource group in which we will create the components of our virtual
machine. We will then create a virtual machine that comes with Visual Studio as part of the OS image.

First look at Azure portal

The Azure portal is divided into 3 segments.

The top bar


The top bar provides quick and universal access to some crucial features so that they are available to you
wherever you are in the Azure portal.

The search box allows you to search for features to create resources or access existing resources you have
already created.

The notifications toggle shows / hides the notifications pane that will let you know just-in-time information such
as when resources are being created or when they are successfully or unsuccessfully created.

The terminal toggle brings up a web-based command line interface (CLI) that allows you to directly input
commands to effect changes to your Azure subscription, without the need for a separate OS or shell.

Page 4 of 32
Azure

The settings icon lets you customize the interface of your Azure portal.

The feedback icon lets you send feedback of your experiences throughout the Azure portal.

The help icon gives you a shortcut to access support tickets and resources. Note that Help + support is
also available from the left pane.

The directory + subscription icon lets you toggle and filter between various subscriptions if you have
more than one.

The left pane


The left pane in the Azure portal contains shortcuts to commonly used features such as resource groups, app
services, SQL databases and virtual machines. You can customize the order of these shortcuts and remove / add
other services to be on this pane. The left pane also lets you create a new resource and access the full menu of
services available on Azure.

The main pane


The main pane is where content relevant to any selected feature or resource will be displayed. By default, it
shows a customizable dashboard where you can choose to pin your important resources or monitoring
statistics. You can also have multiple instances of the dashboard and quickly toggle between them with ease.

Creating a resource group


Resource grouping is a logical way of organizing different kinds of resources according to their logical
purposes. Think of them like folders – you may have a folder for a project, and in it are all kinds of files such as
Word documents, a few Excel spreadsheets and maybe a bunch of pictures. A resource group can contain any
number of Azure resources and it is up to you as the user to define which resources get created in which
resource groups. The most common way to use resource groups is to create a different one per workload.

A resource group is a logical way to organize instances you spin up on Azure.

To create a resource group, click Resource groups on the left side bar and click + Add.

Page 5 of 32
Azure

In the new pane that appears, fill in a relevant resource group name. For this guide, we can use Task1.

Make sure to use the correct subscription. If you followed the pre-requisite defaults, it should be Free
Trial.

We will create all our resources in Southeast Asia as Southeast Asia region’s datacenters are physically located
in Singapore. We will not be using Tags for this lab and hence we can skip it. After that, click Review +
Create and click on Create.

Page 6 of 32
Azure

Creating a virtual machine with Azure Portal

The concept of running a virtual machine (VM) on Azure is very similar to that of doing the same on premise.
You choose an operating system or image, configure the compute, network and storage, and run the VM.
Azure virtual machines support a wide range of operating systems including but not limited to Windows Server,
Windows 10, RedHat Enterprise Linux, Ubuntu, SUSE Linux Enterprise Server, CentOS and more.

During the VM creation, we will be creating the required network and storage resources. A virtual network is an
emulation of a physical network. It is not to be confused with virtual private network (VPN). A virtual network
acts like a local intranet network so Azure resources can communicate privately. This virtual network can be
extended to your on-premise servers and VMs through an Azure ExpressRoute.

Click Virtual machines on the left side bar and then click + Add.

In the Create virtual machine wizard, you will see there are 6 steps – Basics, Disks, Networking,
Management, Guest config and Tags.

Page 7 of 32
Azure

We shall proceed with step 1 – Basics.

Page 8 of 32
Azure

1. Make sure to use the correct subscription. If you followed the pre-requisite defaults, it should be
Free Trial.
2. We will use our existing Task1 resource group to provision our VM.
3. Give your VM a relevant name.
4. Make sure location is set as Southeast Asia.
5. Select “No infrastructure redundancy required” for Availability Options as we will not configure high
availability.
6. For image option, Click on Browse all images and disks.
a. In the Select an image page, search for Visual Studio Community and choose Visual Studio
Community 2017(latest release) on Windows Server 2016 (x64)

7. For Size, click on Change size and select D2s_v3 for VM size. This SKU comes with 2 virtual CPUs and
8 GB of RAM – sufficient for this lab. Do not choose anything lower. Click on Select.

8. Enter a pair of username and password that you can remember.


Do note that the username can contain spaces and special characters.
Also note that the password has the following complexity requirements:
• Must be between 12 and 123 characters long
• Must contain an uppercase character
• Must contain a lowercase character
• Must contain a number
• Must contain a special character

If you have trouble coming up with a password, you can use @MsFt.c0M#ADD
9. We will skip Inbound Port Rules for now.
10. For this lab, we will select No for Save money.

If your organization has an enterprise agreement with Microsoft and you have unused Windows Server
licenses, you may get up to 40% on monthly Windows Server VM billing on Azure. Find out more about
the Azure Hybrid Use Benefit (AHUB).
11. Click Next : Disks >.
Page 9 of 32
Azure

Step 2: Disks

1. We will choose Premium SSD as the OS disk type.


2. Click on Next : Networking >

Page 10 of 32
Azure

Step 3: Networking

1. Under Configure Virtual Networks, click on Create new.

Page 11 of 32
Azure

a. Give your virtual network a relevant name. This field does not have to be unique across Azure.
b. You can configure the address space per your needs. For this lab, we will use the default
10.0.0.0/16
c. Give your subnet a relevant name. This field does not have to be unique across Azure.
d. You can configure the address range per your needs. For this lab, we will use the default
10.0.0.0/16.
e. Click on OK.
2. A new public IP address will be created and assigned to the VM.
3. We will customize the NIC network security group [NSG]. An NSG is essentially a set of firewall
definitions on which ports to open for inbound and outbound traffic.
a. Verify Network security group setting is set to Basic
b. In Public inbound ports, select Allow selected ports
c. Under Select inbound ports, select RDP (3389) from the dropdown
4. Leave the rest of the settings to default value and click on Next : Management >

Step 5: Management

A common cause of high billing is VMs are left running when not in use. This is especially true for DevTest VMs
which may not be used beyond working hours. Since the VM we are creating is not for production but for
training, we will schedule our VM to auto-shutdown at 7pm UTC+8. When a VM is in shutdown state (via the
Azure portal), you will not be billed for compute hours.

Note that to properly shut down a VM such that you are not billed, you need to shut down the VM through the
Azure portal or PowerShell / CLI commands. Shutting down the OS via RDP will not release the compute
resources allocated to your VM and hence you will continue to be billed.

Toggling the notification before shutdown is entirely up to your own preference. Selecting on will result in
you receiving an email notifying you your VM is about the shut down before the shutdown time.
We will leave the pre-populated monitoring and managed service identity settings as is.

Leave the rest of the settings as default and click on Review + create.

Page 12 of 32
Azure

Final Step: Review + create

1. Review the configuration parameters for the VM.


2. If you’d like to download the settings of the VM you have created for future replication through code,
you can click Download template and parameters. This is termed infrastructure-as-code.
3. Click Create. This starts the VM creation process which should take about 5 to 15 minutes.

Page 13 of 32
Azure

Logging in to virtual machine and setting up Visual Studio

Once the virtual machine has been successfully created, you should be automatically brought to the overview
tab of the VM. If not, navigate to Virtual machines on the left pane and click into the VM you just created.

In the overview tab, find the Public IP address and copy it to your clipboard.

Open a remote desktop client. On Windows, launch Remote Desktop Connection from the start menu.
On macOS, you need to download the Microsoft Remote Desktop app from the App Store.

Paste the IP address you just copied into the Computer field in Remote Desktop Connection.

Click Connect and login with your configured credentials.

Click Yes if you encounter a popup asking you to accept the certificate of the remote computer.

Page 14 of 32
Azure

If you forgot your username or password, you may, in the Azure portal, navigate out of the overview tab and into
the Reset password pane to configure a new set of username and password.

You should now be in the remote virtual machine environment.

Page 15 of 32
Azure

Task 2 – Creating a Linux virtual machine in Azure


In this task, we will deploy a virtual machine on Azure using PowerShell commands. The major difference
between Task1 and Task2 is that Azure UI is used in Task1, whereas the bulk of this task will be executed
through PowerShell commands.

Activating Azure PowerShell in Azure Portal

In the Azure portal, click the Cloud Shell icon on the top bar.

In the newly opened window at the bottom of the browser, click PowerShell. Note that you can also create a Bash
cloud shell to execute CLI commands. Choosing one doesn’t mean you forgo the other. You can always access the
Bash cloud shell later.

Click Create storage.

Page 16 of 32
Azure

After a minute, you will be presented with the PowerShell command interface. We will now proceed to creating
a VM using PowerShell commands.

Creating a Linux VM using PowerShell commands

We will start by creating a new resource group that will hold our virtual machine. But, before creating resource
group lets assign few variables that can hold values of resource group, location and virtual machine name.
Execute the below commands one by one:

# Variables for common values


$resourceGroup = "Task2"
$location = "southeastasia"
$vmName = "Task2VM"

Page 17 of 32
Azure

After setting the variables for resource group, let us set variables for secure password and username using the
below commands

# Definer user name and password


$securePassword = ConvertTo-SecureString 'Azure@123Azure@123' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ("azureuser",
$securePassword)

With variables set, we can create Resource group by executing the following command,

# Create a resource group


New-AzureRmResourceGroup -Name $resourceGroup -Location $location

Next step in the VM creation process is configuring subnet with required range of addresses and subnet name
of user’s choice.

# Create a subnet configuration


$subnetConfig = New-AzureRmVirtualNetworkSubnetConfig -Name Task2Subnet -
AddressPrefix 192.168.1.0/24

Create VNET using subnet configuration created in the previous step and assign name for VNET

# Create a virtual network

$vnet = New-AzureRmVirtualNetwork -ResourceGroupName $resourceGroup -Location $location `


-Name Task2vNET -AddressPrefix 192.168.0.0/16 -Subnet $subnetConfig

After the execution of command, a warning might be thrown, and it can be ignored as it does not have any
major impact towards to intent of this lab.

Page 18 of 32
Azure

Now assign a Public IP Address using a unique name. Note that the Get-Random function here is used to
create a random value, making sure that the generated name is unique.

# Create a public IP address and specify a DNS name


$pip = New-AzureRmPublicIpAddress -ResourceGroupName $resourceGroup -Location $location `
-Name "mypublicdns$(Get-Random)" -AllocationMethod Static -IdleTimeoutInMinutes 4

Next step is to create Network Security Group and open the ports that are necessary for this VM. Since this is a
Linux VM, open the port #22 for inbound traffic.

# Create an inbound network security group rule for port 22


$nsgRuleSSH = New-AzureRmNetworkSecurityRuleConfig -Name myNetworkSecurityGroupRuleSSH -
Protocol Tcp `
-Direction Inbound -Priority 1000 -SourceAddressPrefix * -SourcePortRange * -
DestinationAddressPrefix * `
-DestinationPortRange 22 -Access Allow

Creating network security group is a 2-step process. After configuring NSG Rule using previous command,
Network Security Group creation becomes complete with the following command:

# Create a network security group


$nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName $resourceGroup -Location
$location `
-Name myNetworkSecurityGroup -SecurityRules $nsgRuleSSH

The final step before creating VM is to create the Network Interface Card and associate with Public IP address
and Network Security Group created in the earlier steps:

# Create a virtual network card and associate with public IP address and NSG
$nic = New-AzureRmNetworkInterface -Name myNic -ResourceGroupName $resourceGroup -
Location $location `
-SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id -NetworkSecurityGroupId
$nsg.Id

Page 19 of 32
Azure

Set the VM Configuration variable using VM Name, OS Name, Credentials and server name.

# Create a virtual machine configuration


$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize Standard_D1 | `
Set-AzureRmVMOperatingSystem -Linux -ComputerName $vmName -Credential $cred | `
Set-AzureRmVMSourceImage -PublisherName RedHat -Offer RHEL -Skus 7.5 -Version latest | `
Add-AzureRmVMNetworkInterface -Id $nic.Id

# Create a virtual machine


New-AzureRmVM -ResourceGroupName $resourceGroup -Location $location -VM $vmConfig

While the above command gets executed, the subsequent warning can be ignored; but verify that the status
code is OK, which indicates that VM creation is successful.

Once installation is completed, you can navigate back to Azure Portal and Identify the Linux VM that has just
been created and make a note of Public IP address of VM.

Page 20 of 32
Azure

After identifying Public IP address of Linux VM, download putty client from https://www.putty.org/. Launch Putty
and provide your VM credentials (username + password) and it will allow you to access the VM.

Page 21 of 32
Azure

Task 3 - Deploy a Linux Container in Azure Container Instances

Creating a Resource Group

Login to Azure Portal and search for resource groups

Click on Add

Fill the fields on the Basics Tab as below

Page 22 of 32
Click on ‘Review + Create’ and ‘Create’

Configure Azure Container Instances

Search for Container Instances

Click on Add

Page 23 of 32
Fill in the details on the Basic Tab as below

*More Details on Container Image

*Docker Hub is a Public Repository of Images that can be used to deploy in Azure Container Instances. The URL
or Docker Hub Tag helps to uniquely identify an image.

Leave the default Values

Page 24 of 32
Notification Pops Up on Deployment in Progress
Page 25 of 32
The Container shows up in ACI and indicates the status as ‘Creating’

View the Container Events and it lists Pulling, Pulled, Started, Created

Page 26 of 32
Access the Public IP address from the Browser
IP Address: Port Number

Page 27 of 32
Task 4 - Deploy a Windows Container in Azure Container Instances
Search for Container Instances

Click on Add

Fill in the details on the Basic Tab as below and click OK

Container Name – iisserver


Container Image - mcr.microsoft.com/windows/servercore/iis:nanoserver
Resource Group Name – Task3

Page 28 of 32
Page 29 of 32
Click on OK

Select All Resources

Page 30 of 32
Select the IIS Server

Notification Pops Up on the Deployment

Notification pops up to say Deployment Succeeded

The Container is in Running State

Open the Overview Pane and copy the IP Address see on your terminal

Page 31 of 32
Enter the IP Address on the Browser – View the Landing Page of IIS

Page 32 of 32

You might also like