【发布时间】:2020-08-24 07:39:55
【问题描述】:
从最近几天开始,我遇到了一种情况,即我无法对通过附加非托管 Windows vhd 创建的 Azure VM 进行 RDP。 我解释了执行的步骤,
-
从 azure VM msdn 创建了一个非托管 VM 映像 (vhd)
一个。使用非托管 OS 磁盘创建了 Azure VM (Windows Server 2016)。
b.使用 Sysprep msdn 通用化 VM。
c。解除分配 VM 并使用 PowerShell 将状态设置为泛化。
Stop-AzureRmVM -ResourceGroupName '[RG]' -Name '[vhdtest]'
Set-AzureRmVM -ResourceGroupName '[RG]' -Name '[vhdtest]' –Generalized
Save-AzureRmVMImage -ResourceGroupName '[RG]' -Name '[vhdtest]' `
-DestinationContainerName 'newvhds' -VHDNamePrefix 'new3'
我可以看到新的 VHD 已复制到系统 blob 容器中。
- 通过使用 PowerShell 附加在步骤 1 中创建的 VHD,使用非托管磁盘创建了一个 VM。 执行以下步骤或 PowerShell 命令来创建 VM 并附加 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
已创建具有非托管 OS 磁盘的 VM。 问题/问题:无法 RDP 虚拟机。
附加信息:-
如果我使用非托管 OS 磁盘创建相同的 VM,但使用 fromImage 选项而不是 attach,则允许我对 VM 进行 RDP。
【问题讨论】:
标签: azure powershell