获取天蓝色RM中的VM映像的操作系统类型

问题描述 投票:0回答:1

根据this,我们可以获得AzureRM Cloud中的报价,发布者和Sku。

现在如何使用azure中的任何API获取Image的操作系统类型(Windows或Linux)?因为使用this我只能获得Publisher,offer和sku细节,无法获得操作系统类型。

我的问题是如何以编程方式获取任何图像的操作系统类型?

azure azure-virtual-machine azure-resource-manager azure-stack
1个回答
1
投票

您可以使用Azure CLi 2.0来获取操作系统类型。

使用az vm image show,例如:

latest=$(az vm image list -p OpenLogic -s 7.3 --all --query     "[?offer=='CentOS'].version" -o tsv | sort -u | tail -n 1)
az vm image show -l westus -f CentOS -p OpenLogic --s 7.3 --version ${latest}

它将返回以下结果

{
  "additionalProperties": {},
  "dataDiskImages": [],
  "id": "/Subscriptions/*************/Providers/Microsoft.Compute/Locations/westus/Publishers/OpenLogic/ArtifactTypes/VMImage/Offers/CentOS/Skus/7.3/Versions/7.3.20170925",
  "location": "westus",
  "name": "7.3.20170925",
  "osDiskImage": {
    "additionalProperties": {},
    "operatingSystem": "Linux"
  },
  "plan": null,
  "tags": null
}

注意:operatingSystem是您想要的操作系统类型。该示例适用于bash shell。

如果您使用az vm image show -l westus -f CentOS -p OpenLogic --s 7.3 --version ${latest} --debug,您将找到可以获得操作系统类型的API。

GET https://management.azure.com/subscriptions/{subscription id}/providers/Microsoft.Compute/locations/westus/publishers/OpenLogic/artifacttypes/vmimage/offers/CentOS/skus/7.3/versions/7.3.20170925?api-version=2017-12-01

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.