Tuesday, November 27, 2018

How to run Modern Desktop Deployment and Management Lab Kit in Hyper-V in Azure environment


How to run Modern Desktop Deployment and Management Lab Kit in Hyper-V in Azure environment

What you need
-        Enterprise MSDN/visualstudio
-        Activate Azure free credits $150 per month in visualstudio portal
-        Login to azure portal

PART 1

Deploy a VM in azure portal

-        Go to azure portal
-        Click on Virtual Machine resource on left hand panel
-        Click Add
-        Subscription choose Visual Studio Enterprise
-        Resource group create new give a name as you like e.g: Ent-VM
-        Virtual machine name Windows-Server
-        Region south east asia
-        Availability options no infrastructure redundancy required
-        Image windows server 2016 datacenter
-        Size search for E4s_v3 then click select
-        Put your username and password remember it
-        Inbound port rules allow selected ports
-        Select inbound ports RDP (3389)
-        Click Next
-        Create and attach new disk you can accept the default value then click OK
-        Click next networking
-        Click next management
-        Auto shutdown On
-        Shutdown time put at the end of your office hour (e.g 17:00:00)
-        Time zone (UTC +8:00) Kuala Lumpur, Singapore
-        Click Review + Create
-        Click Create
-        Wait for the VM deployment to complete
-        Once completed, start the VM, click Connect and download the RDP file. Then connect using your created username and password for the VM



PART 2

Enabling nested virtualization in an Azure VM
-        On the Azure VM, open PowerShell as an Administrator then run this command
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart
-        Warning - This command restarts the Azure VM. You will lose your RDP connection during the restart process.
-        After the Azure VM restarts, reconnect to your VM using RDP.

Set up internet connectivity for the guest virtual machine
Create a new virtual network adapter for the guest virtual machine and configure a NAT Gateway to enable Internet connectivity.
Create a NAT virtual network switch
1.     On the Azure VM, open PowerShell as an Administrator.
2.     Create an internal switch.
New-VMSwitch -Name "InternalNATSwitch" -SwitchType Internal
3.     View the properties of the switch and note the ifIndex for the new adapter.
Get-NetAdapter
 Note
Take note of the "ifIndex" for the virtual switch you just created.
4.     Create an IP address for the NAT Gateway.
In order to configure the gateway, you need some information about your network:
·        IPAddress - The NAT Gateway IP specifies the IPv4 or IPv6 address to use as the default gateway address for the virtual network subnet. The generic form is a.b.c.1 (for example, "192.168.0.1"). While the final position doesn’t have to be .1, it usually is (based on prefix length). Typically you should use an RFC 1918 private network address space.
·        PrefixLength - The subnet prefix length defines the local subnet size (subnet mask). The subnet prefix length will be an integer value between 0 and 32. 0 would map the entire internet, 32 would only allow one mapped IP. Common values range from 24 to 12 depending on how many IPs need to be attached to the NAT. A common PrefixLength is 24 -- this is a subnet mask of 255.255.255.0.
·        InterfaceIndex - ifIndex is the interface index of the virtual switch created in the previous step.
PowerShellCopy
New-NetIPAddress -IPAddress 192.168.0.1 -PrefixLength 24 -InterfaceIndex 13
Create the NAT network
In order to configure the gateway, you will need to provide information about the network and NAT Gateway:
·        Name - This is the name of the NAT network.
·        InternalIPInterfaceAddressPrefix - The NAT subnet prefix describes both the NAT Gateway IP prefix from above as well as the NAT Subnet Prefix Length from above. The generic form will be a.b.c.0/NAT Subnet Prefix Length.
In PowerShell, create a new NAT network.
PowerShellCopy
New-NetNat -Name "InternalNat" -InternalIPInterfaceAddressPrefix 192.168.0.0/24

Assign an IP address to the guest virtual machine

You can assign an IP address to the guest virtual machine either by manually setting a static IP address on the guest virtual machine or configuring DHCP on the Azure VM to assign the IP address dynamically.

Option 1: Configure DHCP to dynamically assign an IP address to the guest virtual machine

Follow the steps below to configure DHCP on the host virtual machine for dynamic address assignment.

Install DCHP Server on the Azure VM

1.     Open Server Manager. On the Dashboard, click Add roles and features. The Add Roles and Features Wizard appears.
2.     In wizard, click Next until the Server Roles page.
3.     Click to select the DHCP Server checkbox, click Add Features, and then click Next until you complete the wizard.
4.     Click Install.

Configure a new DHCP scope

1.     Open DHCP Manager.
2.     In the navigation pane, expand the server name, right-click IPv4, and click New Scope. The New Scope Wizard appears, click Next.
3.     Enter a Name and Description for the scope and click Next.
4.     Define an IP Range for your DCHP Server (for example, 192.168.0.100 to 192.168.0.200).
5.     Click Next until the Default Gateway page. Enter the IP Address you created earlier (for example, 192.168.0.1) as the Default Gateway.
6.     Click Next until the wizard completes, leaving all default values, then click Finish.














PART 3

Download the Modern Desktop Deployment and Management Lab Kit


Once downloaded, extract the .zip file to your E:\ drive (1TB size). Do not use the temporary D:\ drive as the data will be lost once the VM is reset.
After extracted, open CMD as administrator, go to the extracted folder (e.g: cd E:\MDLAB)
Then run zpaq x SelfService1808.zpaq and wait until completed
Once completed, run the setup as admin. Wait until all VM imported.
*caveat: during the setup, it may prompt that the hyper-v does not have external vSwitch. Create an external vSwitch using Hyper-V manager. Name it as you like as this will not be used later
Open Hyper-V manager, go to HYD-GW1, right click and select settings
Find Intel® 82579LM gigabit Network, change Virtual switch to InternalNATSwitch that was created earlier in PART 2. Then reboot HYD-GW1.