Deploy & Urus VM
Lab: Menyebarkan dan Menguruskan Mesin Maya
Semua tugas dalam makmal ini dilakukan dari portal Azure (termasuk sesi Shell PowerShell Shell) kecuali untuk Latihan 2 Tugasan 2 dan Latihan 2 tugasan 3, yang termasuk langkah-langkah yang dilakukan dari sesi Remote Desktop ke Azure VM
Nota: Apabila tidak menggunakan Cloud Shell, mesin makmal mesti mempunyai modul Azure PowerShell dipasang https://docs.microsoft.com/en-us/powershell/azure/install-Az-ps
Fail makmal:
Perbadanan Adatum ingin melaksanakan beban kerjanya dengan menggunakan mesin-mesin maya Azure (VMs) dan set skala Azure VM
Objektif
Selepas melengkapkan makmal ini, anda akan dapat:
Lab: Menyebarkan dan Menguruskan Mesin Maya
Semua tugas dalam makmal ini dilakukan dari portal Azure (termasuk sesi Shell PowerShell Shell) kecuali untuk Latihan 2 Tugasan 2 dan Latihan 2 tugasan 3, yang termasuk langkah-langkah yang dilakukan dari sesi Remote Desktop ke Azure VM
Nota: Apabila tidak menggunakan Cloud Shell, mesin makmal mesti mempunyai modul Azure PowerShell dipasang https://docs.microsoft.com/en-us/powershell/azure/install-Az-ps
Fail makmal:
- Labfiles \ Module_02 \ Deploy_and_Manage_Virtual_Machines \ az-100-03_azuredeploy.json
- Labfiles \ Module_02 \ Deploy_and_Manage_Virtual_Machines \ az-100-03_azuredeploy.parameters.json
- Labfiles \ Module_02 \ Deploy_and_Manage_Virtual_Machines \ az-100-03_install_iis_vmss.zip
Perbadanan Adatum ingin melaksanakan beban kerjanya dengan menggunakan mesin-mesin maya Azure (VMs) dan set skala Azure VM
Objektif
Selepas melengkapkan makmal ini, anda akan dapat:
- Menggunakan Azure VM dengan menggunakan portal Azure, Azure PowerShell, dan Azure Resource Manager template
- Konfigurasikan tetapan rangkaian Azure VM yang menjalankan sistem operasi Windows dan Linux.
The main tasks for this exercise are as follows:
- Deploy an Azure VM running Windows Server 2016 Datacenter into an availability set by using the Azure portal
- Deploy an Azure VM running Windows Server 2016 Datacenter into the existing availability set by using Azure PowerShell
- Deploy two Azure VMs running Linux into an availability set by using an Azure Resource Manager template
Task 1: Deploy an Azure VM running Windows Server 2016 Datacenter into an availability set by using the Azure portal
- From the lab virtual machine, start Microsoft Edge, browse to the Azure portal at http://portal.azure.com and sign in by using a Microsoft account that has the Owner role in the Azure subscription you intend to use in this lab.
- In the Azure portal, navigate to the Create a resource blade.
- From the Create a resource blade, search Azure Marketplace for Windows Server. Select Windows Server from the search results list.
- On the Windows Server page, use the drop-down menu to select [smalldisk] Windows Server 2016 Datacenter, and then click Create.
- Use the Create a virtual machine blade to deploy a virtual machine with the following settings:
- Subscription: the name of the subscription you are using in this lab
- Resource group: the name of a new resource group az1000301-RG
- Virtual machine name: az1000301-vm0
- Region: (US) East US (or a region closer to you)Note: To identify Azure regions where you can provision Azure VMs, refer to https://azure.microsoft.com/en-us/regions/offers/
- Availability options: Availability set
- Availability set: Click Create New, and name the new availability set az1000301-avset0 with 2 fault domains and 5 update domains. Click OK.
- Image: [smalldisk] Windows Server 2016 Datacenter
- Size: Standard DS2_v2
- Username: Student
- Password: Pa55w.rd1234
- Public inbound ports: None
- Click Next: Disks >.
- OS disk type: Standard HDD
- Click Next: Networking >.
- On the Networking tab, click Create new under Virtual Network. Use the virtual network name already assigned by default, delete the default address range and specify the following:
- Virtual network address range: 10.103.0.0/16
- Subnet name: subnet0
- Click OK.
- On the Management tab, set Boot diagnostics to Off and leave all other settings with their default vaules.
- On the Advanced tab, review the available settings.
- Click Create.Note: You will configure the network security group you create in this task in the second exercise of this lab
Task 2: Deploy an Azure VM running Windows Server 2016 Datacenter into the existing availability set by using Azure PowerShell
- From the Azure Portal, start a PowerShell session in the Cloud Shell pane.Note: If this is the first time you are launching the Cloud Shell in the current Azure subscription, you will be asked to create an Azure file share to persist Cloud Shell files. If so, accept the defaults, which will result in creation of a storage account in an automatically generated resource group.
- In the Cloud Shell pane, run the following command:
$vmName = 'az1000301-vm1' $vmSize = 'Standard_DS2_v2'
Note: This sets the values of variables designating the Azure VM name and its size - In the Cloud Shell pane, run the following commands:
$resourceGroup = Get-AzResourceGroup -Name 'az1000301-RG' $location = $resourceGroup.Location
Note: These commands set the values of variables designating the target resource group and its location - In the Cloud Shell pane, run the following commands:
$availabilitySet = Get-AzAvailabilitySet -ResourceGroupName $resourceGroup.ResourceGroupName -Name 'az1000301-avset0' $vnet = Get-AzVirtualNetwork -Name 'az1000301-RG-vnet' -ResourceGroupName $resourceGroup.ResourceGroupName $subnetid = (Get-AzVirtualNetworkSubnetConfig -Name 'subnet0' -VirtualNetwork $vnet).Id
- In the Cloud Shell pane, run the following commands:
$nsg = New-AzNetworkSecurityGroup -ResourceGroupName $resourceGroup.ResourceGroupName -Location $location -Name "$vmName-nsg" $pip = New-AzPublicIpAddress -Name "$vmName-ip" -ResourceGroupName $resourceGroup.ResourceGroupName -Location $location -AllocationMethod Dynamic $nic = New-AzNetworkInterface -Name "$($vmName)$(Get-Random)" -ResourceGroupName $resourceGroup.ResourceGroupName -Location $location -SubnetId $subnetid -PublicIpAddressId $pip.Id -NetworkSecurityGroupId $nsg.Id
Note: These commands create a new network security group, public IP address, and network interface that will be used by the new Azure VMNote: You will configure the network security group you create in this task in the second exercise of this lab - In the Cloud Shell pane, run the following commands:
$adminUsername = 'Student' $adminPassword = 'Pa55w.rd1234' $adminCreds = New-Object PSCredential $adminUsername, ($adminPassword | ConvertTo-SecureString -AsPlainText -Force)
Note: These commands set the values of variables designating credentials of the local Administrator account of the new Azure VM - In the Cloud Shell pane, run the following commands:
$publisherName = 'MicrosoftWindowsServer' $offerName = 'WindowsServer' $skuName = '2016-Datacenter'
Note: These commands set the values of variables designating the properties of the Azure Marketplace image that will be used to provision the new Azure VM - In the Cloud Shell pane, run the following command:
$osDiskType = (Get-AzDisk -ResourceGroupName $resourceGroup.ResourceGroupName)[0].Sku.Name
Note: This command sets the values of a variable designating the operating system disk type of the new Azure VM - In the Cloud Shell pane, run the following commands:
$vmConfig = New-AzVMConfig -VMName $vmName -VMSize $vmSize -AvailabilitySetId $availabilitySet.Id Add-AzVMNetworkInterface -VM $vmConfig -Id $nic.Id Set-AzVMOperatingSystem -VM $vmConfig -Windows -ComputerName $vmName -Credential $adminCreds Set-AzVMSourceImage -VM $vmConfig -PublisherName $publisherName -Offer $offerName -Skus $skuName -Version 'latest' Set-AzVMOSDisk -VM $vmConfig -Name "$($vmName)_OsDisk_1_$(Get-Random)" -StorageAccountType $osDiskType -CreateOption fromImage Set-AzVMBootDiagnostic -VM $vmConfig -Disable
Note: These commands set up the properties of the Azure VM configuration object that will be used to provision the new Azure VM, including the VM size, its availability set, network interface, computer name, local Administrator credentials, the source image, the operating system disk, and boot diagnostics settings. - In the Cloud Shell pane, run the following command:
New-AzVM -ResourceGroupName $resourceGroup.ResourceGroupName -Location $location -VM $vmConfig
Note: This command initiates deployment of the new Azure VM
Task 3: Deploy two Azure VMs running Linux into an availability set by using an Azure Resource Manager template
- In the Azure portal, navigate to the Create a resource blade.
- From the Create a resource blade, search Azure Marketplace for Template deployment, and select Template deployment (deploy using custom templates).
- Click Create.
- On the Custom deployment blade, click the Build your own template in the editor link. If you do not see this link, click Edit template instead.
- From the Edit template blade, load the template file Labfiles\Module_02\Deploy_and_Manage_Virtual_Machines\az-100-03_azuredeploy.json.Note: Review the content of the template and note that it defines deployment of two Azure VMs hosting Linux Ubuntu into an availability set and into the existing virtual network az1000301-vnet0. This virtual network does not exist in your deployment. You will be changing the virtual network name in the parameters below.
- Save the template and return to the Custom deployment blade.
- From the Custom deployment blade, navigate to the Edit parameters blade.
- Save the parameters and return to the Custom deployment blade.
- From the Custom deployment blade, initiate a template deployment with the following settings:
- Subscription: the name of the subscription you are using in this lab
- Resource group: the name of a new resource group az1000302-RG
- Location: the same Azure region you chose earlier in this exercise
- Vm Name Prefix: az1000302-vm
- Nic Name Prefix: az1000302-nic
- Pip Name Prefix: az1000302-ip
- Admin Username: Student
- Admin Password: Pa55w.rd1234
- Image Publisher: Canonical
- Image Offer: UbuntuServer
- Image SKU: 16.04.0-LTS
- Vm Size: use Standard_DS1_v2 or Standard_DS2_v2, based on the instructor's recommendations
- Virtual Network Name: az1000301-RG-vnet
- Virtual Network Resource Group: the name of a new resource group az1000301-RG
- Subnet Name: subnet0
Result: After you completed this exercise, you have deployed an Azure VM running Windows Server 2016 Datacenter into an availability set by using the Azure portal, deployed another Azure VM running Windows Server 2016 Datacenter into the same availability set by using Azure PowerShell, and deployed two Azure VMs running Linux Ubuntu into an availability set by using an Azure Resource Manager template.
Note: You could certainly use a template to deploy two Azure VMs hosting Windows Server 2016 datacenter in a single task (just as this was done with two Azure VMs hosting Linux Ubuntu server). The reason for deploying these Azure VMs in two separate tasks was to give you the opportunity to become familiar with both the Azure portal and Azure PowerShell-based deployments.
Exercise 2: Configure networking settings of Azure VMs running Windows and Linux operating systems
The main tasks for this exercise are as follows:
- Configure static private and public IP addresses of Azure VMs
- Connect to an Azure VM running Windows Server 2016 Datacenter via a public IP address
- Connect to an Azure VM running Linux Ubuntu Server via a private IP address
Task 1: Configure static private and public IP addresses of Azure VMs
- In the Azure portal, navigate to the az1000301-vm0 blade.
- From the az1000301-vm0 blade, navigate to the Networking blade, displaying the configuration of the public IP address az1000301-vm0-ip, assigned to its network interface.
- From the Networking blade, click the link representing the public IP address.
- On the az1000301-vm0-ip blade, click Configuration.
- Change the assignment of the public IP address to Static, and then click Save.Note: Take a note of the public IP address assigned to the network interface of az1000301-vm0. You will need it later in this exercise.
- In the Azure portal, navigate to the az1000302-vm0 blade.
- From the az1000302-vm0 blade, display the Networking blade.
- On the az1000302-vm0 - Networking blade, click the entry representing network interface (with name starting with az1000302-vm0).
- From the blade displaying the properties of the network interface of az1000302-vm0, navigate to its IP configurations blade.
- On the IP configurations blade, configure the ipconfig1 private IP address to be static and set it to 10.103.0.100, and then click Save.Note: Changing the private IP address assignment requires restarting the Azure VM.Note: It is possible to connect to Azure VMs via either statically or dynamically assigned public and private IP addresses. Choosing static IP assignment is commonly done in scenarios where these IP addresses are used in combination with IP filtering, routing, or if they are assigned to network interfaces of Azure VMs that function as DNS servers.
Task 2: Connect to an Azure VM running Windows Server 2016 Datacenter via a public IP address
- In the Azure portal, navigate to the az1000301-vm0 blade.
- From the az1000301-vm0 blade, navigate to the Networking blade.
- On the az1000301-vm0 - Networking blade, review the inbound port rules of the network security group assigned to the network interface of az1000301-vm0.Note: The default configuration consisting of built-in rules block inbound connections from the internet (including connections via the RDP port TCP 3389)
- Add an inbound security rule to the existing network security group with the following settings:
- Source: Any
- Source port ranges: *
- Destination: Any
- Destination port ranges: 3389
- Protocol: TCP
- Action: Allow
- Priority: 100
- Name: AllowInternetRDPInBound
- In the Azure portal, display the Overview pane of the az1000301-vm0 blade.
- From the Overview pane of the az1000301-vm0 blade, click Connect and generate an RDP file and use it to connect to az1000301-vm0.
- When prompted, authenticate by specifying the following credentials:
- User name: Student
- Password: Pa55w.rd1234
Task 3: Connect to an Azure VM running Linux Ubuntu Server via a private IP address
- Within the RDP session to az1000301-vm0, start Command Prompt.
- From the Command Prompt, run the following:
nslookup az1000302-vm0
- Examine the output and note that the name resolves to the IP address you assigned in the first task of this exercise (10.103.0.100).Note: This is expected. Azure provides built-in DNS name resolution within a virtual network.
- Within the RDP session to az1000301-vm0, from Server Manager, click Local Server, then disable IE Enhanced Security Configuration.
- Within the RDP session to az1000301-vm0, start Internet Explorer and download putty.exe from https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
- Use putty.exe to verify that you can successfully connect to az1000302-vm0 on its private IP address(10.103.0.100) via the SSH protocol (TCP 22).
- When prompted, authenticate by specifying the following values:
- User name: Student
- Password: Pa55w.rd1234
Note: Both the username and password are case sensitive. - Once you successfully authenticated, terminate the RDP session to az1000301-vm0.
- On the lab virtual machine, in the Azure portal, navigate to the az1000302-vm0 blade.
- From the az1000302-vm0 blade, navigate to the Networking blade.
- On the az1000302-vm0 - Networking blade, review the inbound port rules of the network security group assigned to the network interface of az1000301-vm0 to determine why your SSH connection via the private IP address was successsful.Note: The default configuration consisting of built-in rules allows inbound connections within the Azure virtual network environment (including connections via the SSH port TCP 22).
Result: After you completed this exercise, you have configured static private and public IP addresses of Azure VMs, connected to an Azure VM running Windows Server 2016 Datacenter via a public IP address, and connect to an Azure VM running Linux Ubuntu Server via a private IP address
Exercise 3: Deploy and configure Azure VM scale sets
The main tasks for this exercise are as follows:
- Identify an available DNS name for an Azure VM scale set deployment
- Deploy an Azure VM scale set
- Install IIS on a scale set VM by using DSC extensions
Task 1: Identify an available DNS name for an Azure VM scale set deployment
- From the Azure Portal, start a PowerShell session in the Cloud Shell pane.
- In the Cloud Shell pane, run the following command, substituting the placeholder <custom-label> with any string which is likely to be unique.
$rg = Get-AzResourceGroup -Name az1000301-RG Test-AzDnsAvailability -DomainNameLabel <custom-label> -Location $rg.Location
- Verify that the command returned True. If not, rerun the same command with a different value of the <custom-label> until the command returns True.
- Note the value of the <custom-label> that resulted in the successful outcome. You will need it in the next task
Task 2: Deploy an Azure VM scale set
- In the Azure portal, navigate to the Create a resource blade.
- From the Create a resource blade, search Azure Marketplace for Virtual machine scale set.
- Use the list of search results to navigate to the Create virtual machine scale set blade.
- Use the Create virtual machine scale set blade to deploy a virtual machine scale set with the following settings:
- Virtual machine scale set name: az1000303vmss0
- Operating system disk image: Windows Server 2016 Datacenter
- Subscription: the name of the subscription you are using in this lab
- Resource group: the name of a new resource group az1000303-RG
- Location: the same Azure region you chose in the previous exercises of this lab
- Availability zone: None
- Username: Student
- Password: Pa55w.rd1234
- Instance count: 1
- Instance size: DS2 v2
- Deploy as low priority: No
- Use managed disks: Yes
- Autoscale: Disabled
- Choose Load balancing options: Load balancer
- Public IP address name: az1000303vmss0-ip
- Domain name label: type in the value of the <custom-label> you identified in the previous task
- Virtual network: the name of a new virtual network az1000303-vnet0 with the following settings:
- Address range: 10.203.0.0/16
- Subnet name: subnet0
- Subnet address range: 10.203.0.0/24
- Public IP address per instance: Off
- Accelerated networking: Off
- NIC network security group: Basic
- Select inbound ports: HTTP
- Boot diagnostics: Off
- System assigned managed identity: Off
Note: Wait for the deployment to complete before you proceed to the next task. This should take about 5 minutes.
Task 3: Install IIS on a scale set VM by using DSC extensions
- In the Azure portal, navigate to the az1000303vmss0 blade.
- From the az1000303vmss0 blade, display its Extension blade.
- From the az1000303vmss0 - Extension blade, add the PowerShell Desired State Configuration extension with the following settings:Note: The DSC configuration module is available for upload from Labfiles\Module_02\Deploy_and_Manage_Virtual_Machines\az-100-03_install_iis_vmss.zip. The module contains the DSC configuration script that installs the Web Server (IIS) role.
- Configuration Modules or Script: "az-100-03_install_iis_vmss.zip"
- Module-qualified Name of Configuration: az-100-03_install_iis_vmss.ps1\IISInstall
- Configuration Arguments: leave blank
- Configuration Data PSD1 File: leave blank
- WMF Version: latest
- Data Collection: Disable
- Version: 2.76
- Auto Upgrade Minor Version: Yes
- Navigate to the az1000303vmss0 - Instances blade and click on Upgrade to initiate the upgrade of the az1000303vmss0_0 instance.Note: The update will trigger application of the DSC configuration script. Wait for upgrade to complete. This should take about 5 minutes. You can monitor the progress from the az1000303vmss0 - Instances blade.
- Once the upgrade completes, navigate to the Overview blade.
- On the az1000303vmss0-ip blade, note the public IP address assigned to az1000303vmss0.
- Start Microsoft Edge and navigate to the public IP address you identified in the previous step.
- Verify that the browser displays the default IIS home page.
Result: After you completed this exercise, you have identified an available DNS name for an Azure VM scale set deployment, deployed an Azure VM scale set, and installed IIS on a scale set VM by using the DSC extension.
Exercise 4: Remove lab resources
Task 1: Open Cloud Shell
- At the top of the portal, click the Cloud Shell icon to open the Cloud Shell pane.
- At the Cloud Shell interface, select Bash.
- At the Cloud Shell command prompt, type in the following command and press Enter to list all resource groups you created in this lab:
az group list --query "[?starts_with(name,'az1000')].name" --output tsv
- Verify that the output contains only the resource groups you created in this lab. These groups will be deleted in the next task.
Task 2: Delete resource groups
- At the Cloud Shell command prompt, type in the following command and press Enter to delete the resource groups you created in this lab
az group list --query "[?starts_with(name,'az1000')].name" --output tsv | xargs -L1 bash -c 'az group delete --name $0 --no-wait --yes'
- Close the Cloud Shell prompt at the bottom of the portal.
Ulasan
Catat Ulasan