Azure:从通用映像部署 VM 时出错(映像无法部署)
Azure: Error Deploying VM from Generalised Image (Image Undeployable)
我一直在尝试使用 Powershell(遵循 MS 文档)从通用映像部署新 VM,但我一直收到此错误。
New-AzureRmVM : Long running operation failed with status 'Failed'.
ErrorCode: OSProvisioningClientError
ErrorMessage: OS provisioning for VM 'MyVM' failed. Error details: This installation of Windows is undeployable. Make sure the image has been properly prepared (generalized).
Instructions for Windows: https://azure.microsoft.com/documentation/articles/virtual-machines-windows-upload-image/
StartTime: 22/03/2017 10:06:24
EndTime: 22/03/2017 10:10:37
OperationID: 549f97d1-ca39-4bc5-bd6c-65e37a8d398f
Status: Failed
At C:\Visual Studio Projects\Deployment\VmSetup.ps1:97 char:1
+ New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vm
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureRmVM], ComputeCloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand
问题是我做了 运行 sysprep 并概括了图像。
Code : OSState/generalized
Level : Info
DisplayStatus : VM generalized
Message :
Time :
我也无法再次启动 VM,因为它告诉我它已通用化。
Failed to start virtual machine 'OtherVM'. Error: Operation 'start' is not allowed on VM 'OtherVM' since the VM is generalized.
图片保存脚本:
#Script to save image
$vmName = "OtherVM"
$rgName = "MyResourceGroup"
#Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName
Set-AzureRmVM -ResourceGroupName $rgName -Name $vmName -Generalized
$vm = Get-AzureRmVM -ResourceGroupName $rgName -Name $vmName -Status
$vm.Statuses
#Save VM Image
Save-AzureRmVMImage -ResourceGroupName $rgName -Name $vmName `
-DestinationContainerName "generalisedimages" -VHDNamePrefix "gen" `
#-Path "C:\VMTemplate\VmTemplate.json"
Write-Output "Imaged saved."
和部署脚本。
#
# VmDeploy.ps1
#
#Sign into Azure account
#Login-AzureRmAccount
# Name of the virtual machine. This example sets the VM name as "myVM".
$vmName = "MyVM"
#Set resource group and subnet name
$rgName = "MyResourceGroup"
$subnetName = "default"
$singleSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
#Set location and vNet name
$location = "UK South"
$vnetName = "{0}-vnet" -f $rgName
$vnet = New-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $rgName -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $singleSubnet
#Create public IP
$ipName = "{0}-ip" -f $vmName
$pip = New-AzureRmPublicIpAddress -Name $ipName -ResourceGroupName $rgName -Location $location -AllocationMethod Dynamic
#Create NIC
$nicName = "{0}-nic" -f $vmName
$nic = New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $rgName -Location $location -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id
#Create network security group and allow RDP
$nsgName = "{0}-nsg" -f $vmName
$rdpRule = New-AzureRmNetworkSecurityRuleConfig -Name Rdp -Description "Allow RDP" `
-Access Allow -Protocol Tcp -Direction Inbound -Priority 110 `
-SourceAddressPrefix Internet -SourcePortRange * `
-DestinationAddressPrefix * -DestinationPortRange 3389
$httpRule = New-AzureRmNetworkSecurityRuleConfig -Name Http -Description "Allow HTTP" `
-Access Allow -Protocol Tcp -Direction Inbound -Priority 120 `
-SourceAddressPrefix Internet -SourcePortRange * `
-DestinationAddressPrefix * -DestinationPortRange 80
$httpsRule = New-AzureRmNetworkSecurityRuleConfig -Name Https -Description "Allow HTTPS" `
-Access Allow -Protocol Tcp -Direction Inbound -Priority 130 `
-SourceAddressPrefix Internet -SourcePortRange * `
-DestinationAddressPrefix * -DestinationPortRange 443
$nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName $rgName -Location $location -Name $nsgName -SecurityRules $rdpRule, $httpRule, $httpsRule
#Get completed virtual network
$vnet = Get-AzureRmVirtualNetwork -ResourceGroupName $rgName -Name $vnetName
#Uri of VM image
$imageURI = "https://*******.blob.core.windows.net/system/Microsoft.Compute/Images/generalisedimages/genosDisk.86g419f6-0de6-4331-hi54-32hse8de6bd4.vhd"
# Enter a new user name and password to use as the local administrator account
# for remotely accessing the VM.
$cred = Get-Credential
# Name of the storage account where the VHD is located. This example sets the
# storage account name as "myStorageAccount"
$storageRgName = $rgName
$storageAccName = "mystorage"
# Size of the virtual machine. This example creates "Standard_D2_v2" sized VM.
# See the VM sizes documentation for more information:
# https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/
$vmSize = "Standard_A1"
# Computer name for the VM. This examples sets the computer name as "myComputer".
$computerName = "New VM"
# Name of the disk that holds the OS. This example sets the
# OS disk name as "myOsDisk"
$osDiskName = "OsDisk"
# Assign a SKU name. This example sets the SKU name as "Standard_LRS"
# Valid values for -SkuName are: Standard_LRS - locally redundant storage, Standard_ZRS - zone redundant
# storage, Standard_GRS - geo redundant storage, Standard_RAGRS - read access geo redundant storage,
# Premium_LRS - premium locally redundant storage.
$skuName = "Standard_LRS"
# Get the storage account where the uploaded image is stored
$storageAcc = Get-AzureRmStorageAccount -ResourceGroupName $storageRgName -AccountName $storageAccName
Write-Output $storageAcc
# Set the VM name and size
$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize $vmSize
#Set the Windows operating system configuration and add the NIC
$vm = Set-AzureRmVMOperatingSystem -VM $vmConfig -Windows -ComputerName $computerName `
-Credential $cred -ProvisionVMAgent -EnableAutoUpdate
$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id
# Create the OS disk URI
$osDiskUri = '{0}vhds/{1}-{2}.vhd' `
-f $storageAcc.PrimaryEndpoints.Blob.ToString(), $vmName.ToLower(), $osDiskName
Write-Output "OS Disk URI:" $osDiskUri
# Configure the OS disk to be created from the existing VHD image (-CreateOption fromImage).
$vm = Set-AzureRmVMOSDisk -VM $vm -Name $osDiskName -VhdUri $osDiskUri -CreateOption fromImage -SourceImageUri $imageURI -Windows
Write-Output $vm
# Create the new VM
New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vm
$vmList = Get-AzureRmVM -ResourceGroupName $rgName
$vmList.Name
OS provisioning for VM 'MyVM' failed. Error details: This installation
of Windows is undeployable. Make sure the image has been properly
prepared (generalized).
根据错误消息,您似乎没有 正确地通用化 VM。
我们应该 RDP 到 Azure VM 和 运行 sysprep,在系统准备工具对话框中,select 进入系统开箱即用体验 (OOBE),并确保概括复选框已 selected。在关机选项中,select 关机。
有关通用化 Windows 虚拟机的更多信息,请参阅此 link。
I'm also unable to start the VM again because it's told me it's
generalised
捕获 Azure widnows VM 的映像,此过程在捕获后 删除 原始虚拟机。
在捕获 Azure 虚拟机的映像之前,建议备份目标虚拟机
我一直在尝试使用 Powershell(遵循 MS 文档)从通用映像部署新 VM,但我一直收到此错误。
New-AzureRmVM : Long running operation failed with status 'Failed'.
ErrorCode: OSProvisioningClientError
ErrorMessage: OS provisioning for VM 'MyVM' failed. Error details: This installation of Windows is undeployable. Make sure the image has been properly prepared (generalized).
Instructions for Windows: https://azure.microsoft.com/documentation/articles/virtual-machines-windows-upload-image/
StartTime: 22/03/2017 10:06:24
EndTime: 22/03/2017 10:10:37
OperationID: 549f97d1-ca39-4bc5-bd6c-65e37a8d398f
Status: Failed
At C:\Visual Studio Projects\Deployment\VmSetup.ps1:97 char:1
+ New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vm
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureRmVM], ComputeCloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand
问题是我做了 运行 sysprep 并概括了图像。
Code : OSState/generalized
Level : Info
DisplayStatus : VM generalized
Message :
Time :
我也无法再次启动 VM,因为它告诉我它已通用化。
Failed to start virtual machine 'OtherVM'. Error: Operation 'start' is not allowed on VM 'OtherVM' since the VM is generalized.
图片保存脚本:
#Script to save image
$vmName = "OtherVM"
$rgName = "MyResourceGroup"
#Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName
Set-AzureRmVM -ResourceGroupName $rgName -Name $vmName -Generalized
$vm = Get-AzureRmVM -ResourceGroupName $rgName -Name $vmName -Status
$vm.Statuses
#Save VM Image
Save-AzureRmVMImage -ResourceGroupName $rgName -Name $vmName `
-DestinationContainerName "generalisedimages" -VHDNamePrefix "gen" `
#-Path "C:\VMTemplate\VmTemplate.json"
Write-Output "Imaged saved."
和部署脚本。
#
# VmDeploy.ps1
#
#Sign into Azure account
#Login-AzureRmAccount
# Name of the virtual machine. This example sets the VM name as "myVM".
$vmName = "MyVM"
#Set resource group and subnet name
$rgName = "MyResourceGroup"
$subnetName = "default"
$singleSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
#Set location and vNet name
$location = "UK South"
$vnetName = "{0}-vnet" -f $rgName
$vnet = New-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $rgName -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $singleSubnet
#Create public IP
$ipName = "{0}-ip" -f $vmName
$pip = New-AzureRmPublicIpAddress -Name $ipName -ResourceGroupName $rgName -Location $location -AllocationMethod Dynamic
#Create NIC
$nicName = "{0}-nic" -f $vmName
$nic = New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $rgName -Location $location -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id
#Create network security group and allow RDP
$nsgName = "{0}-nsg" -f $vmName
$rdpRule = New-AzureRmNetworkSecurityRuleConfig -Name Rdp -Description "Allow RDP" `
-Access Allow -Protocol Tcp -Direction Inbound -Priority 110 `
-SourceAddressPrefix Internet -SourcePortRange * `
-DestinationAddressPrefix * -DestinationPortRange 3389
$httpRule = New-AzureRmNetworkSecurityRuleConfig -Name Http -Description "Allow HTTP" `
-Access Allow -Protocol Tcp -Direction Inbound -Priority 120 `
-SourceAddressPrefix Internet -SourcePortRange * `
-DestinationAddressPrefix * -DestinationPortRange 80
$httpsRule = New-AzureRmNetworkSecurityRuleConfig -Name Https -Description "Allow HTTPS" `
-Access Allow -Protocol Tcp -Direction Inbound -Priority 130 `
-SourceAddressPrefix Internet -SourcePortRange * `
-DestinationAddressPrefix * -DestinationPortRange 443
$nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName $rgName -Location $location -Name $nsgName -SecurityRules $rdpRule, $httpRule, $httpsRule
#Get completed virtual network
$vnet = Get-AzureRmVirtualNetwork -ResourceGroupName $rgName -Name $vnetName
#Uri of VM image
$imageURI = "https://*******.blob.core.windows.net/system/Microsoft.Compute/Images/generalisedimages/genosDisk.86g419f6-0de6-4331-hi54-32hse8de6bd4.vhd"
# Enter a new user name and password to use as the local administrator account
# for remotely accessing the VM.
$cred = Get-Credential
# Name of the storage account where the VHD is located. This example sets the
# storage account name as "myStorageAccount"
$storageRgName = $rgName
$storageAccName = "mystorage"
# Size of the virtual machine. This example creates "Standard_D2_v2" sized VM.
# See the VM sizes documentation for more information:
# https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/
$vmSize = "Standard_A1"
# Computer name for the VM. This examples sets the computer name as "myComputer".
$computerName = "New VM"
# Name of the disk that holds the OS. This example sets the
# OS disk name as "myOsDisk"
$osDiskName = "OsDisk"
# Assign a SKU name. This example sets the SKU name as "Standard_LRS"
# Valid values for -SkuName are: Standard_LRS - locally redundant storage, Standard_ZRS - zone redundant
# storage, Standard_GRS - geo redundant storage, Standard_RAGRS - read access geo redundant storage,
# Premium_LRS - premium locally redundant storage.
$skuName = "Standard_LRS"
# Get the storage account where the uploaded image is stored
$storageAcc = Get-AzureRmStorageAccount -ResourceGroupName $storageRgName -AccountName $storageAccName
Write-Output $storageAcc
# Set the VM name and size
$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize $vmSize
#Set the Windows operating system configuration and add the NIC
$vm = Set-AzureRmVMOperatingSystem -VM $vmConfig -Windows -ComputerName $computerName `
-Credential $cred -ProvisionVMAgent -EnableAutoUpdate
$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id
# Create the OS disk URI
$osDiskUri = '{0}vhds/{1}-{2}.vhd' `
-f $storageAcc.PrimaryEndpoints.Blob.ToString(), $vmName.ToLower(), $osDiskName
Write-Output "OS Disk URI:" $osDiskUri
# Configure the OS disk to be created from the existing VHD image (-CreateOption fromImage).
$vm = Set-AzureRmVMOSDisk -VM $vm -Name $osDiskName -VhdUri $osDiskUri -CreateOption fromImage -SourceImageUri $imageURI -Windows
Write-Output $vm
# Create the new VM
New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vm
$vmList = Get-AzureRmVM -ResourceGroupName $rgName
$vmList.Name
OS provisioning for VM 'MyVM' failed. Error details: This installation of Windows is undeployable. Make sure the image has been properly prepared (generalized).
根据错误消息,您似乎没有 正确地通用化 VM。
我们应该 RDP 到 Azure VM 和 运行 sysprep,在系统准备工具对话框中,select 进入系统开箱即用体验 (OOBE),并确保概括复选框已 selected。在关机选项中,select 关机。
有关通用化 Windows 虚拟机的更多信息,请参阅此 link。
I'm also unable to start the VM again because it's told me it's generalised
捕获 Azure widnows VM 的映像,此过程在捕获后 删除 原始虚拟机。
在捕获 Azure 虚拟机的映像之前,建议备份目标虚拟机