M365 Available License Count Monitor

Microsoft.SystemCenter.M365.Monitor.LicenseCount (UnitMonitor)

This monitor determines if the number of available of M365 licenses is greater than the set thresholds.

Knowledge Base article:

Summary

This monitor verifies that number of available licenses for a particular SKU is greater than the set threshold. The “License Verification Profile” is used to run the workflow. This monitor has three health states, healthy, warning and critical. The health state is determined

by running the Get-AzureADSubscribedSku and then we need to make sure we actually have a license to assign. To determine that, we take the value of PrePaidUnits property (25) and subtract the value of the ConsumedUnits (24) property:

25 - 24 = 1

The PrePaidUnits property tells us how many licenses we’ve purchased, and the value ConsumedUnits tells us how many licenses are currently in use. If we subtract the number of licenses already spoken for from the number of licenses we purchased, we’ll know how many licenses are still available.

Causes

An error state is caused by having issues with connecting to Microsoft 365, fetching data or if available licenses are insufficient. It can be caused by the following:

Resolutions

Resolution depends on the specific error. Verify and/or fix the following:

Element properties:

TargetMicrosoft.SystemCenter.M365.WatcherNodeApplication.Licensing
Parent MonitorMicrosoft.SystemCenter.M365.Monitor.Availability.WatcherNode.Licensing
CategoryAvailabilityHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityMatchMonitorHealth
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SystemCenter.M365.Monitor.LicenseCount.UnitMonitorType
RemotableTrue
AccessibilityPublic
Alert Message
M365 Available License Count Monitor: Failure
{0}
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SystemCenter.M365.Monitor.LicenseCount" Accessibility="Public" Enabled="true" Target="Microsoft.SystemCenter.M365.WatcherNodeApplication.Licensing" ParentMonitorID="Microsoft.SystemCenter.M365.Monitor.Availability.WatcherNode.Licensing" Remotable="true" Priority="Normal" TypeID="Microsoft.SystemCenter.M365.Monitor.LicenseCount.UnitMonitorType" ConfirmDelivery="false">
<Category>AvailabilityHealth</Category>
<AlertSettings AlertMessage="Microsoft.SystemCenter.M365.Monitor.LicenseCount.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Data/Context/Property[@Name='Alert Message']$</AlertParameter1>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Success" MonitorTypeStateID="Healthy" HealthState="Success"/>
<OperationalState ID="Warning" MonitorTypeStateID="Warning" HealthState="Warning"/>
<OperationalState ID="Error" MonitorTypeStateID="Critical" HealthState="Error"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>14400</IntervalSeconds>
<AzureADEndpoint>$Target/Host/Property[Type="Microsoft.SystemCenter.M365.WatcherNodeApplication"]/AzureADEndpoint$</AzureADEndpoint>
<GraphEndpoint>$Target/Host/Property[Type="Microsoft.SystemCenter.M365.WatcherNodeApplication"]/GraphEndpoint$</GraphEndpoint>
<TenantId>$Target/Host/Property[Type="Microsoft.SystemCenter.M365.WatcherNodeApplication"]/TenantId$</TenantId>
<ApplicationClientId>$RunAs[Name="Microsoft.SystemCenter.M365.RunAsProfile.ApplicationClient"]/UserName$</ApplicationClientId>
<ApplicationClientCredentials>$RunAs[Name="Microsoft.SystemCenter.M365.RunAsProfile.ApplicationClient"]/Password$</ApplicationClientCredentials>
<SkuPartNumber>$Target/Property[Type="Microsoft.SystemCenter.M365.WatcherNodeApplication.Licensing"]/SkuPartNumber$</SkuPartNumber>
<CriticalThresholdPercentage>$Target/Host/Property[Type="Microsoft.SystemCenter.M365.WatcherNodeApplication"]/RemainingLicensesErrorPercentageThreshold$</CriticalThresholdPercentage>
<WarningThresholdPercentage>$Target/Host/Property[Type="Microsoft.SystemCenter.M365.WatcherNodeApplication"]/RemainingLicensesWarningPercentageThreshold$</WarningThresholdPercentage>
<MatchCount>1</MatchCount>
</Configuration>
</UnitMonitor>