无法使用 Powershell 创建 Azure VM
Unable to create Azure VM using Powershell
在 windows 10 上使用 PS 5. 0
我创建了一个 Azure 存储帐户和一个 Azure 服务。使用以下命令获取最新的图像名称。但是当我 运行 使用以下命令创建 VM 时,出现以下错误:
PS 获取最新图片的命令:
$images = Get-AzureVMImage `
| where { $_.ImageFamily -eq “Windows Server 2012 Datacenter” } `
| Sort-Object -Descending -Property PublishedDate
$latestImage = $images[0]
$latestImage
上面的命令 运行 成功并给了我图像名称: a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-20171017-en.us-127GB.vhd
我在下面的命令中使用它来创建 VM
.
PS 创建虚拟机的命令:
New-AzureVMConfig -Name "Server15" -InstanceSize ExtraSmall -ImageName "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-20171017-en.us-127GB.vhd" | Add-AzureProvisioningConfig -Windows -AdminUsername "MyAdmin" -Password "MyPsswd" | New-AzureVM -ServiceName "MyServiceName"
错误:
WARNING: No deployment found in service: 'MyServiceName'.
New-AzureVM : BadRequest: OSImage a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-20171017-en.us-127GB.vhd
not found. If you are using a VM image, it must be specified as VMImageName for the role, not as SourceImageName for
OSVirtualHardDisk.
OperationID : '498779aecff53369ac9e793da15c16c3'
At line:1 char:250
+ ... d "D7v.oeiue4ieiur" | New-AzureVM -ServiceName "MyServiceName"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureVM], ComputeCloudException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.PersistentVMs.NewAzureVMCommand
你的脚本对我有用,这是输出:
PS C:\Users\jason> New-AzureVMConfig -Name "Server16" -InstanceSize ExtraSmall -ImageName "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-20171017-en.us-127GB.vhd" | Add-AzureProvisioningConfig -Windows -AdminUse
rname "jason" -Password "xxxxxxx" | New-AzureVM -ServiceName "jasontest321"
OperationDescription OperationId OperationStatus
-------------------- ----------- ---------------
New-AzureVM 05a8d386-ac4b-3843-8fe4-1018325112a3 Succeeded
请检查您的 Azure PowerShell 版本,目前最新版本是 5.0.1
,我的 Azure PowerShell 版本是 4.4.1
,脚本运行良好,也许我们应该升级您的 Azure PowerShell。
我们可以下载Azure PowerShell 5.0.1 installer到你的Windows10上安装,然后再测试。
更多关于Azure PowerShell版本的信息,请参考这里link。
希望对您有所帮助。
在 windows 10 上使用 PS 5. 0
我创建了一个 Azure 存储帐户和一个 Azure 服务。使用以下命令获取最新的图像名称。但是当我 运行 使用以下命令创建 VM 时,出现以下错误:
PS 获取最新图片的命令:
$images = Get-AzureVMImage `
| where { $_.ImageFamily -eq “Windows Server 2012 Datacenter” } `
| Sort-Object -Descending -Property PublishedDate
$latestImage = $images[0]
$latestImage
上面的命令 运行 成功并给了我图像名称: a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-20171017-en.us-127GB.vhd
我在下面的命令中使用它来创建 VM
.
PS 创建虚拟机的命令:
New-AzureVMConfig -Name "Server15" -InstanceSize ExtraSmall -ImageName "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-20171017-en.us-127GB.vhd" | Add-AzureProvisioningConfig -Windows -AdminUsername "MyAdmin" -Password "MyPsswd" | New-AzureVM -ServiceName "MyServiceName"
错误:
WARNING: No deployment found in service: 'MyServiceName'.
New-AzureVM : BadRequest: OSImage a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-20171017-en.us-127GB.vhd
not found. If you are using a VM image, it must be specified as VMImageName for the role, not as SourceImageName for
OSVirtualHardDisk.
OperationID : '498779aecff53369ac9e793da15c16c3'
At line:1 char:250
+ ... d "D7v.oeiue4ieiur" | New-AzureVM -ServiceName "MyServiceName"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureVM], ComputeCloudException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.PersistentVMs.NewAzureVMCommand
你的脚本对我有用,这是输出:
PS C:\Users\jason> New-AzureVMConfig -Name "Server16" -InstanceSize ExtraSmall -ImageName "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-20171017-en.us-127GB.vhd" | Add-AzureProvisioningConfig -Windows -AdminUse
rname "jason" -Password "xxxxxxx" | New-AzureVM -ServiceName "jasontest321"
OperationDescription OperationId OperationStatus
-------------------- ----------- ---------------
New-AzureVM 05a8d386-ac4b-3843-8fe4-1018325112a3 Succeeded
请检查您的 Azure PowerShell 版本,目前最新版本是 5.0.1
,我的 Azure PowerShell 版本是 4.4.1
,脚本运行良好,也许我们应该升级您的 Azure PowerShell。
我们可以下载Azure PowerShell 5.0.1 installer到你的Windows10上安装,然后再测试。
更多关于Azure PowerShell版本的信息,请参考这里link。
希望对您有所帮助。