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

      

  • 相关阅读:
    androidstudio配置http proxy以及配置gradle
    发布jar到docker的方法
    idea直接发布项目到docker中
    安卓启动相机报错android.os.FileUriExposedException: file:///storage/emulated/0/
    centos 7.4搭建Harbor、push docker镜像以及常见错误
    dock的卸载与安装
    centos部署Kubernetes(k8s)集群
    Logback将日志输出到Kafka配置示例
    JavaScript设计模式 Item 5 --链式调用
    你不知道的JavaScript--Item27 异步编程异常解决方案
  • 原文地址:https://www.cnblogs.com/oceanwang/p/8405266.html
Copyright © 2011-2022 走看看