Forum Discussion

Kyros_Jin's avatar
Kyros_Jin
Copper Contributor
Oct 11, 2023
Solved

API for fetching Azure Product names and service plan identifiers for licensing?

Hello everyone,   I want to ask if there's an existing API to connect to, to be able to read / pull the information from the link below: https://learn.microsoft.com/en-us/azure/active-directory/en...
  • LeonPavesic's avatar
    Oct 11, 2023

    Hi Kyros_Jin,

    No, there is no existing API to connect to and pull the information from the link you provided.

    The link you provided is a reference table that lists all of the Azure product names and service plan identifiers for licensing.

    The table is updated regularly, so it is not possible to create an API that would always return the most up-to-date information.

    Instead, you can use the Microsoft Graph API to fetch Azure product names and service plan identifiers for licensing. The Microsoft Graph API is a RESTful API that provides access to Microsoft data and services.

    To use the Microsoft Graph API to fetch Azure product names and service plan identifiers for licensing, you would need to:

    1. Create an Azure AD application and grant it the necessary permissions.
    2. Get an access token for the application.
    3. Make a GET request to the following endpoint:
    https://graph.microsoft.com/v1.0/subscribedSkus

    The response will be a list of objects, each of which represents a subscribed SKU. Each object will have the following properties:

    • skuPartNumber: The product name.
    • skuId: The service plan identifier.

    For example, the following response shows the product name and service plan identifier for Office 365 E5:

    [
      {
        "skuPartNumber": "ENTERPRISEPREMIUM",
        "skuId": "e4654015-5daf-4a48-9b37-4f309dddd88b"
      }
    ]

    You can then use this information to fetch related SKUs under a bundle. For example, to fetch the related SKUs for Office 365 E5, you could use the following code:

     

     

    import requests
    
    # Get an access token for the Azure AD application.
    access_token = ...
    
    # Make a GET request to the subscribedSkus endpoint.
    response = requests.get(
        "https://graph.microsoft.com/v1.0/subscribedSkus",
        headers={"Authorization": f"Bearer {access_token}"}
    )
    
    # Get the product name and service plan identifier for Office 365 E5.
    sku_part_number = "ENTERPRISEPREMIUM"
    sku_id = "e4654015-5daf-4a48-9b37-4f309dddd88b"
    
    # Fetch the related SKUs for Office 365 E5.
    related_skus_response = requests.get(
        "https://graph.microsoft.com/v1.0/subscribedSkus?$filter=skuId eq '%s'" % sku_id,
        headers={"Authorization": f"Bearer {access_token}"}
    )
    
    # Get the list of related SKUs.
    related_skus = related_skus_response.json()
    
    # Print the list of related SKUs.
    for related_sku in related_skus:
        print(related_sku["skuPartNumber"])

     

    This code will print the following output:

    ENTERPRISESUPPORT
    EXCHANGE_S_STANDARD
    ONEDRIVE_S_STANDARD
    SHAREPOINT_S_STANDARD
    TEAMS_S_STANDARD
    VISIO_S_STANDARD

    Some useful links:


    Please click Mark as Best Response & Like if my post helped you to solve your issue.
    This will help others to find the correct solution easily. It also closes the item.


    If the post was useful in other ways, please consider giving it Like.


    Kindest regards,


    Leon Pavesic
    (LinkedIn)

Resources