From the last few days I am encountering a scenario where I am not able to RDP an Azure VM created via attaching an unmanaged windows vhd. I explain the steps performed,
Created a unmanaged VM image (vhd) from an azure VM msdn
a. Created an Azure VM (Windows Server 2016) with unmanaged OS Disk.
b. Generalize the VM using Sysprep msdn.
c. Deallocated the VM and set the state to generalize using PowerShell.
Stop-AzureRmVM -ResourceGroupName '[RG]' -Name '[vhdtest]'
Set-AzureRmVM -ResourceGroupName '[RG]' -Name '[vhdtest]' –Generalized
Save-AzureRmVMImage -ResourceGroupName '[RG]' -Name '[vhdtest]' `
-DestinationContainerName 'newvhds' -VHDNamePrefix 'new3'
I can see the new VHD got copied at system blob container.
- Created a VM with the unmanaged disk by attaching VHD created in step 1 Using PowerShell. Performed following steps or PowerShell commands to create VM and attach the VHD,
# created Subnet
$rgName = "Technovate2020_Logicators-RG"
$subnetName = "mySubNet-attach"
$singleSubnet = New-AzureRMVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
# created virtual Network with assignig Subnet
$location = "CentralUS"
$vnetName = "myVnetName-attach"
$vnet = New-AzureRMVirtualNetwork -Name $vnetName -ResourceGroupName $rgName -Location $location `
-AddressPrefix 10.0.0.0/16 -Subnet $singleSubnet
# created Network Security Group rule to enable RDP
$nsgName = "myNsg-attach"
$rdpRule = New-AzureRMNetworkSecurityRuleConfig -Name myRdpRule -Description "Allow RDP" `
-Access Allow -Protocol Tcp -Direction Inbound -Priority 110 `
-SourceAddressPrefix Internet -SourcePortRange * `
-DestinationAddressPrefix * -DestinationPortRange 3389
# created Network Security Group and assiging rules
$nsg = New-AzureRMNetworkSecurityGroup -ResourceGroupName $rgName -Location $location `
-Name $nsgName -SecurityRules $rdpRule
# created Public IP
$ipName = "myIP-attach"
$pip = New-AzureRMPublicIpAddress -Name $ipName -ResourceGroupName $rgName -Location $location `
-AllocationMethod Dynamic
# created Network Interface Card
$nicName = "myNicName-attach"
$nic = New-AzureRMNetworkInterface -Name $nicName -ResourceGroupName $rgName `
-Location $location -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id -NetworkSecurityGroupId $nsg.Id
# created VM Configurations
$vmName = "myVM-attach"
$vmConfig = New-AzureRMVMConfig -VMName $vmName -VMSize "Standard_D4s_v3"
# Assign NIC
$vm = Add-AzureRMVMNetworkInterface -VM $vmConfig -Id $nic.Id
# Unmanaged OS Disk to attach (already copied the vhd from 'system' container to 'vhds')
$osDiskUri = "https://technovate2020logicators.blob.core.windows.net/vhds/new3-osDisk.vhd"
# assigning OS Disk using 'attach' option
$osDiskName = $vmName + "osDisk"
$vm = Set-AzureRMVMOSDisk -VM $vm -Name $osDiskName -VhdUri $osDiskUri -CreateOption attach -Windows
#Create the VM
New-AzureRMVM -ResourceGroupName $rgName -Location $location -VM $vm
VM with unmanaged OS Disk created. Issue/problem: Cannot RDP the VM.
Additional information:-
If I create the same VM with unmanaged OS Disk, but using fromImage
option instead of attach
then I am allowed RDP the VM.