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"
              },
    

      

  • 相关阅读:
    用定时器令P0(或其它IO口)产生多路方波
    边沿触发和电平触发的区别
    mysql数据库学习小结
    线程状态、同步
    java访问修饰符 public protect default private
    注解Responsebody RequestBody RequestMapping
    input标签元素,value属性取值问题,赋值
    java多线程的三种实现方式
    参数添加 dynamo
    Python 第三方库,模块,包的安装方法
  • 原文地址:https://www.cnblogs.com/oceanwang/p/8405266.html
Copyright © 2011-2022 走看看