Create an Azure VM based on the prepared VHD
This is the fourth post of a series which describes how to deploy the downloadable VHD for Microsoft Dynamics 365 Finance and Operations as an Azure VM. If you want to read the previous post, please use the following navigation:
Before you can upload the VHD you have to create a storage account within a resource group. Please remember the resource group because you will need it later in the process again. You should select the datacenter of your choice in the dialog for the creation of the new storage account and in addition to that I should change the replication type to LRS, because it is the cheapest option.
When you finished the creation, you can upload the VHD by using the Storage Explorer. The result of this step you can see in the banner of this post. The VHD has been uploaded to https://d365fovhd.blob.core.windows.net/vhd/80-PU15-Fixed.vhd within the resource group d365FO-VHD.
While waiting for the upload of the 128GB VHD to finish, you can already install the PowerShell module which you need for the next step and sign in with your Azure account by using the following commands:
Install-Module AzureRM -RequiredVersion 6.0.0
After the upload is completed you can create a new managed disk from the recently uploaded VHD. Of course you can create the managed disk (again) by using the Azure portal, but I would use the following PowerShell command because it is more streamlined:
$location = ‘eastus’
$destinationResourceGroup = ‘d365FO-VHD’
$osDiskName = ’80-PU15′
$osDiskConfig = New-AzureRmDiskConfig -AccountType StandardSSD_LRS -Location $location -CreateOption Import -SourceUri $sourceUri
$osDisk = New-AzureRmDisk -DiskName $osDiskName -Disk $osDiskConfig -ResourceGroupName $destinationResourceGroup
The final steps are the creation of the virtual network, network security group, public IP address, network interface and off course the VM itself. Most of the steps are possible via Azure portal, but I haven’t found away to use an existing managed disk as the OS disk for a new VM. So I would recommend to use the following PowerShell command to complete those steps:
$vmName = “80-PU15”
$singleSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name ‘default’ -AddressPrefix 10.0.0.0/24
$vnet = New-AzureRmVirtualNetwork -Name $vmName”-vnet” -ResourceGroupName $destinationResourceGroup -Location $location -AddressPrefix 10.0.0.0/24 -Subnet $singleSubnet
$rdpRule = New-AzureRmNetworkSecurityRuleConfig -Name myRdpRule -Description “Allow RDP” -Access Allow -Protocol Tcp -Direction Inbound -Priority 110 -SourceAddressPrefix Internet -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389
$nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName $destinationResourceGroup -Location $location -Name $vmName”-nsg” -SecurityRules $rdpRule
$pip = New-AzureRmPublicIpAddress -Name $vmName”-ip” -ResourceGroupName $destinationResourceGroup -Location $location -AllocationMethod Dynamic
$nic = New-AzureRmNetworkInterface -Name $vmName”-nic” -ResourceGroupName $destinationResourceGroup -Location $location -SubnetId $vnet.Subnets.Id -PublicIpAddressId $pip.Id -NetworkSecurityGroupId $nsg.Id
$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize “Standard_B4ms”
$vm = Add-AzureRmVMNetworkInterface -VM $vmConfig -Id $nic.Id
$vm = Set-AzureRmVMOSDisk -VM $vm -ManagedDiskId $osDisk.Id -StorageAccountType Standard_LRS -DiskSizeInGB 128 -CreateOption Attach -Windows
New-AzureRmVM -ResourceGroupName $destinationResourceGroup -Location $location -VM $vm
When you can see the new created VM in the Azure portal I would recommend to do the following manual settings/steps:
– Change storage account type of the managed disk to Standard SSD. The script creates the disk as Standard SSD, but when you connect the VM with the disk the API only supports Standard HDD, so you have to change it afterwards.
Click path: Virtual machine – Disks – Hyperlink on disk name – Configuration
– Setup auto-shutdown to save money at nighttime and on weekends. Do not forget to set the correct time zone for the scheduled shutdown.
Click path: Virtual machine – Auto-shutdown
– Activate Azure hybrid benefit in case your using a MSDN subscription.
Click path: Virtual machine – Configuration – Azure hybrid benefit
– Set DNS name on the created public IP address to do not always have to change the RDP-File to the new (dynamics) IP address.
Click path: Public IP address – Configuration – DNS name label