Closed sayanghosh123 closed 4 years ago
@sayanghosh123 AFAIK below is the query you can use to fetch license type information.
resources | where type =~ 'Microsoft.Compute/virtualMachines'| extend licenseType = tostring(properties.['licenseType'])
If you opt ' Yes' as shown below then 'licenseType' property is provided in 'properties' column of the query's output.
Typical values for 'licenseType' property are ''Windows_Server" (for Windows server images like 2019 DC, etc.) and "Windows_Client" (for Windows client images like Win 10, etc.)
@sayanghosh123 Closing this issue for now. If there are further questions or feedback regarding referred Azure document then please let us know so that we will gladly continue the discussion.
Thanks @KrishnaG-MSFT - you are awesome! That seems to work. Just one final clarification -
This seems to show "Windows_Server" where AHB is used, and blank elsewhere. Portal shows
@sayanghosh123 Sure. Please find my response below.
"Not supported" for Linux (I assume query will show blank)
Yes, query will show blank under 'licenseType' column
"Not enabled" for Windows where AHB is not used (I assume query will show blank)
Yes, query will show blank under 'licenseType' column
"Azure hybrid benefit" for Windows where AHB is used (I assume query will show "Windows_Server") Is that a correct read?
Yes, query will show "Windows_Server" under 'licenseType' column
Thanks @KrishnaG-MSFT - you are awesome!
here a version to only get Windows VM and summarize the result:
Resources
| where type =~ 'Microsoft.Compute/virtualMachines' and properties.storageProfile.osDisk.osType =~ 'Windows'
| summarize count() by tostring(properties.['licenseType'])
I can get a no of things about VMs from "resources | where type =~ 'Microsoft.Compute/virtualMachines'" and then expanding the properties. What I am looking for is the Windows license type. The same information is available on the portal under "Virtual Machines" - add Columns - "OS licensing benefit". The values are of type "Azure hybrid benefit", "Not enabled" etc.
I can get the same information for SQL Server on IaaS via properties.sqlServerLicenseType in microsoft.sqlvirtualmachine/sqlvirtualmachines, so guessing there is a way to get it for VMs? Any feedback will be greatly appreciated.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.