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?
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