0

According to this we can get the offer , publisher and Sku in AzureRM Cloud .

Now How to get the Image's OS type(Windows or Linux) using any of the API in azure ? Because using this I can be only able to get the Publisher , offer and sku details , Can't get the OS type .

My Question is how to get the OS type for any images programmatically?

Arun Kumar G R
  • 178
  • 2
  • 13
  • I got it ! But I need it in Azure Cloud !https://adminmanagement.local.azurestack.external/subscriptions//providers/Microsoft.Compute.Admin/locations/local/artifactTypes/platformImage?api-version=2015-12-01-preview – Arun Kumar G R Jan 03 '18 at 12:08
  • azure stack has virtually the same api, so just query it like you would with Azure – 4c74356b41 Jan 03 '18 at 18:31
  • @4c74356b41 I got the Answer for Azure Stack , I have updated the question . I need it in Azure RM ,. I have Sku, publisher ,offer and also version . can I get the OsType of the platform image? – Arun Kumar G R Jan 03 '18 at 19:14

1 Answers1

1

You could use Azure CLi 2.0 to get OS type.

Using az vm image show, for example:

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}

It will return following result

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

Note:operatingSystem is the OS type you want. The example works on bash shell.

If you use az vm image show -l westus -f CentOS -p OpenLogic --s 7.3 --version ${latest} --debug, you will find the API that could get the OS type.

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

Shui shengbao
  • 18,746
  • 3
  • 27
  • 45