Get-AzureRMVmImage cmdlet未列出所有可用的vm映像

Mit*_*tul 4 azure azure-virtual-machine azure-powershell azure-resource-manager

我正在尝试使用AzureRM获取所有可用的VM映像Get-AzureRMVMImage,它不会列出任何图像,如命令Get-AzureVMImage

如果我按照帮助中给出的示例,Get-AzureRMVmImage那么它不会列出该Ubuntu VM.下面是我试图获取Windows 2012 R2 Datacenter Image.

PS C:\> Get-AzureRMVMImage -location "Central us" -publisherName "Microsoft" -offer "Windows Server 2012 R2 DataCenter"
Get-AzureRmVMImage : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Get-AzureRMVMImage -location "Central us" -publisherName "Microsoft"  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-AzureRmVMImage], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.Azure.Commands.Compute.GetAzureVMImageCommand
Run Code Online (Sandbox Code Playgroud)

使用参数列出可用的RM vm图像的正确cmdlet是什么?

Mic*_*l B 9

您遇到的问题是您要查找的图像不存在.您的要约和出版商名称都不正确.

要查找图像,您需要按特定顺序浏览一组cmdlet.

首先,你得到了正确的出版商

Get-AzureRmVMImagePublisher -Location westeurope  
Run Code Online (Sandbox Code Playgroud)

可能很难知道您需要从该特定列表中选择哪个Microsoft发布者.但是,如果您将结果插入

Get-AzureRmVMImageOffer -Location westeurope `
                        -PublisherName microsoft  
Run Code Online (Sandbox Code Playgroud)

这使用'microsoft'发布者名称并给出此列表

提供

IBM
JDK
Oracle_Database_11g_R2
Oracle_Database_11g_R2_and_WebLogic_Server_11g Oracle_Database_12c
Oracle_Database_12c_and_WebLogic_Server_12c
Oracle_WebLogic_Server_11g
Oracle_WebLogic_Server_12c

显然不是你想要的!如果再次查看发布者列表,则会出现这种情况

Get-AzureRmVMImageOffer -Location westeurope `
                        -PublisherName MicrosoftWindowsServer
Run Code Online (Sandbox Code Playgroud)

这使

提供

的WindowsServer

然后你需要找到sku

Get-AzureRmVMImagesku -Location westeurope `
                      -PublisherName MicrosoftWindowsServer `
                      -Offer windowsserver
Run Code Online (Sandbox Code Playgroud)

单品

2008-R2-SP1
2012-Datacenter
2012-R2-Datacenter
2016-Nano-Docker-Test
2016-Nano-Server-Technical-Preview
2016-Technical-Preview-with-Containers Windows-Server-Technical-Preview

所以在那件事的最后,你正在寻找的命令是

Get-AzureRMVMImage -location "Central us" `
                   -publisherName "MicrosoftWindowsServer" `
                   -sku "2012-R2-Datacenter" `
                   -Offer windowsserver
Run Code Online (Sandbox Code Playgroud)

对于此特定图像,还有一些版本需要考虑,因此一旦运行,您可以选择要使用的版本,以便获得您将使用的最新版本

Get-AzureRMVMImage -location "Central us" `
                   -publisherName "MicrosoftWindowsServer" `
                   -sku "2012-R2-Datacenter" `
                   -Offer windowsserver `
                   -Version 4.0.20160229
Run Code Online (Sandbox Code Playgroud)