1

I need to determine if the edition of AzureAD in use is Premium or not.

How do I determine that in C#?

Rohit Saigal
  • 9,317
  • 2
  • 20
  • 32
Dana Epp
  • 509
  • 1
  • 5
  • 13

1 Answers1

1

You can make use of Microsoft Graph APIs, either through Microsoft Graph .NET Client Library or through direct HTTP calls. The relevant API is:

Also, note that for information about edition of Azure AD you could have a mix of services enabled in the same Azure AD and licenses are purchased/assigned on a per user basis.

SubscribedSkus API mentioned above is pretty detailed and it gives you information about enabled capabilities as well as number of licenses available, consumed etc.

Here's a similar thread on MSDN forums, you should also look at, it only talks about portal but still concept is relevant: How to check Azure AD edition.

Here is an example that will print all active subscribed SKUs that include an Azure AD Premium service plan:

// There are various Azure AD versions and editions. Here we're only counting
// Azure AD Premium Plan 1 and Azure AD Premium Plan 2. 
var azureAdPlans = new[] { "AAD_PREMIUM", "AAD_PREMIUM_P2" };

// Get all subscribed SKUs
var subscribedSkus = graphClient
    .SubscribedSkus
    .Request().GetAsync().GetAwaiter().GetResult();

// Filter down the results to only active subscribed SKUs with Azure AD service plans.
var skusWithAzureAd = subscribedSkus
    .Where(sku => (sku.CapabilityStatus == "Enabled" || sku.CapabilityStatus == "Warning")
                && (sku.ServicePlans.Any(p => azureAdPlans.Contains(p.ServicePlanName))));

// Print out the results
foreach (var sku in skusWithAzureAd)
{
    Console.WriteLine(
        "{0} ({1}/{2} seats used)", 
        sku.SkuPartNumber, 
        sku.ConsumedUnits, 
        sku.PrepaidUnits.Enabled + sku.PrepaidUnits.Warning);
}
Philippe Signoret
  • 13,299
  • 1
  • 40
  • 58
Rohit Saigal
  • 9,317
  • 2
  • 20
  • 32
  • Thanks. Your link to the other thread brings up an interesting thing. It's possible to have a sku that indirectly gives AAD Premium. How can you detect for that? Check for AAD_PREMIUM or EMS? Is there any other sku to watch for? – Dana Epp Nov 10 '18 at 16:04
  • @DanaEpp even I'm not sure about all such possible values but I have seen AAD_PREMIUM and also ENTERPRISEPREMIUM – Rohit Saigal Nov 12 '18 at 01:05
  • @DanaEpp To get all SKUs which include Azure AD Premium service plans, you can need to filter on the `ServicePlan` property of each `SubscribedSku` object. I've added an edit with an example. – Philippe Signoret Nov 12 '18 at 14:14
  • Thats perfect. Thanks for the insights guys. I found this link useful when trying to figure out what offers AAD_PREMIUM: https://learn.microsoft.com/en-us/azure/active-directory/users-groups-roles/licensing-service-plan-reference – Dana Epp Nov 12 '18 at 16:48