def get_azure_access_token(
    tenant_id, client_id, client_secret, resource_url, scope
):
    """
    Obtains an access token from Azure Active Directory (Azure AD) using the
    OAuth 2.0 client credentials grant flow. Access tokens are used to
    authenticate requests made to Azure services.
    Parameters:
        - tenant_id (str): The ID of the Azure AD tenant where the application
            is registered.
        - client_id (str): The application's client ID in Azure AD.
        - client_secret (str): The application's client secret.
        - resource_url (str): The URL of the resource or service you want to
            access.
        - scope (str): The desired scope of permissions for the access token.

    Returns:
        - access_token (str): The access token that can be used to authenticate
            requests to Azure services.
    """
    authority_url = "https://login.microsoftonline.com/{}/oauth2/token".format(
        tenant_id
    )
    response = requests.post(
        authority_url,
        data={
            "grant_type": "client_credentials",
            "client_id": client_id,
            "client_secret": client_secret,
            "resource": resource_url,
            "scope": scope,
        },
    )
    access_token = response.json()["access_token"]
    return access_token

    Obtains an access token from Azure Active Directory (Azure AD) using the
    OAuth 2.0 client credentials grant flow. Access tokens are used to
    authenticate requests made to Azure services.
    Parameters:
        - tenant_id (str): The ID of the Azure AD tenant where the application
            is registered.
        - client_id (str): The application's client ID in Azure AD.
        - client_secret (str): The application's client secret.
        - resource_url (str): The URL of the resource or service you want to
            access.
        - scope (str): The desired scope of permissions for the access token.

    Returns:
        - access_token (str): The access token that can be used to authenticate
            requests to Azure services.
    
Solutions/CohesitySecurity/Tests/az.py