zoukankan      html  css  js  c++  java
  • Azure Powershell 获取可用镜像 PublisherName,Offer,Skus,Version

    #登录
    $username="{登录名}"  #定义一个用户账号的变量,可以输入需要登录的订阅账号名称
    $password=ConvertTo-SecureString -String "{密码}" -AsPlainText -Force #对密码进行转换字符加密
    $cred= New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username,$password #定义登录的密钥
    Login-AzureRmAccount -EnvironmentName AzureChinaCloud -Credential $cred #登录
    
    # 选择订阅
    Get-AzureRmSubscription | select Name, SubscriptionId
    $subscriptionId=Read-Host "请选择上面列出的订阅ID:"#多种订阅条件下,因订阅不同,所以要选择一个默认订阅
    Write-Host "Selecting subscription '$subscriptionId'";
    Select-AzureRmSubscription -SubscriptionID $subscriptionId;
    
    
    ###############获取订阅下可用的image,并打印image信息
    $images = New-Object System.Collections.ArrayList;
    $location = "China North";
    $publishers = Get-AzureRmVMImagePublisher -Location $location;
    
    foreach($publisher in $publishers)
     {
        $offers = Get-AzureRmVMImageOffer -Location $location -PublisherName $publisher.PublisherName;
        foreach($offer in $offers)
        {
            $skus = Get-AzureRmVMImageSku -Location $location -PublisherName $publisher.PublisherName -Offer $offer.Offer;
            foreach($sku in $skus)
            {
                $image = Get-AzureRmVMImage -Location $location -PublisherName $publisher.PublisherName -Offer $offer.Offer -Skus $sku.Skus;
                Write-Output $image  #打印
                $images.Add($image);
            }
        }
        }
    
    foreach($image in $images)
    {
        $len = $image.Count;
        if ($len -gt 0)
        {
            $image[$len-1] | select PublisherName,Offer,Skus,Version;
        }
    }

    在ARM模板中引用镜像时,一般Version参数为 latest,其他几个参数需要指定

     "imageReference": {
                "publisher": "[variables('imagePublisher')]",
                "offer": "[variables('imageOffer')]",
                "sku": "[variables('imageSku')]",
                "version": "latest"
              },
    

      

  • 相关阅读:
    ios正在使用NSDateComponents、NSDate、NSCalendar它的结论是在当前时间是在一段时间在一天。
    linux 核心学习书籍
    Hbase在的应用经验的统计
    09-使用for循环输出空心菱形(循环)
    [置顶] Android下实现自动关机的方法总结
    S3C3440看门狗驱动程序
    MySQL里求给定的时间是所在月份的第几个礼拜
    CheckBox in ListView
    根据复选框后面的描述文字进行选择的技巧
    C#中一些易混知识的比较
  • 原文地址:https://www.cnblogs.com/oceanwang/p/8405266.html
Copyright © 2011-2022 走看看