【问题标题】:Get-AzureRMVmImage cmdlet doesn't list all the available vm imagesGet-AzureRMVmImage cmdlet 未列出所有可用的 vm 映像
【发布时间】:2016-08-17 09:53:09
【问题描述】:

我正在尝试使用 Get-AzureRMVMImage 获取 AzureRM 的所有可用 VM 映像,但它没有像命令 Get-AzureVMImage 那样列出任何映像

如果我按照Get-AzureRMVmImage 帮助中给出的示例进行操作,那么它不会列出该 Ubuntu 虚拟机。下面是我尝试获取 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

列出可用 RM vm 映像的正确 cmdlet 是什么?

【问题讨论】:

    标签: azure azure-virtual-machine azure-powershell azure-resource-manager


    【解决方案1】:

    您遇到的问题是您要查找的图像不存在。您拥有的报价和发布者名称都不正确。

    要查找图像,您需要按特定顺序执行一组 cmdlet。

    所以首先你用

    找到正确的发布者
    Get-AzureRmVMImagePublisher -Location westeurope  
    

    可能很难知道您需要从该特定列表中选择哪个 Microsoft 出版商。但是,如果将结果插入

    Get-AzureRmVMImageOffer -Location westeurope `
                            -PublisherName microsoft  
    

    这使用“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
    

    这给了

    报价

    Windows 服务器

    然后您需要使用

    查找 sku
    Get-AzureRmVMImagesku -Location westeurope `
                          -PublisherName MicrosoftWindowsServer `
                          -Offer windowsserver
    

    Skus

    2008-R2-SP1
    2012-数据中心
    2012-R2-数据中心
    2016-Nano-Docker-测试
    2016-Nano-Server-技术-预览
    2016-Technical-Preview-with-Containers Windows-服务器-技术-预览

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

    Get-AzureRMVMImage -location "Central us" `
                       -publisherName "MicrosoftWindowsServer" `
                       -sku "2012-R2-Datacenter" `
                       -Offer windowsserver
    

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

    Get-AzureRMVMImage -location "Central us" `
                       -publisherName "MicrosoftWindowsServer" `
                       -sku "2012-R2-Datacenter" `
                       -Offer windowsserver `
                       -Version 4.0.20160229
    

    【讨论】:

    • 此 cmdlet 设计不当。我认为这应该列出所有图像,并且当您提供一个参数时,它应该只过滤这些图像。感谢您的回答。
    • @Mitul 我同意,使用起来确实感觉很笨拙,但我想它是基于支持大量图像的想法而构建的,单次运行下载是不可行的跨度>
    【解决方案2】:

    这不会像 Mitul 那样列出所有图像。那将只列出一张图片。你怎么知道没有其他出版商在 Windows 2012 R2 上有所作为?

    这将更类似于原始功能。您指定位置,然后通过管道输出到下一个命令。虽然,这比旧的 Azure PowerShell 慢很多。

    Get-AzureRmVMImagePublisher -Location 'East US' | Get-AzureRmVMImageOffer | Get-AzureRmVMImageSku | Get-AzureRMVMImage | Get-AzureRmVMImage
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-02
    • 1970-01-01
    • 2021-11-11
    相关资源
    最近更新 更多