Forum Discussion

SakethPatchava's avatar
SakethPatchava
Frequent Visitor
1 year ago
Solved

What is the power bi rest api code to enhanced compute engine details of a dataflow?

what is the code of rest api to get one dataflow enhanced compute engine details. And I have to get details of enhanced compute engine of all the dataflows across the workspace. is there a way to do this.

 

Thanks

  • v-hashadapu's avatar
    v-hashadapu
    1 year ago

    Hi SakethPatchava , Thank you for reaching out to the Microsoft Community Forum.

    To retrieve the Enhanced Compute Engine details for a specific dataflow and for all dataflows in a Power BI workspace using the Power BI REST API, follow these steps:

    1. For a specific Dataflow, use Rest API Endpoint. Example: GET https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/dataflows/{dataflowId}. The enhancedComputeEngine property in the response indicates whether the Enhanced Compute Engine is enabled.
    2. To get the Enhanced Compute Engine details for all dataflows, First, retrieve all dataflows in the workspace. Example: GET https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/dataflows. Then, loop through each dataflow and call the first endpoint to fetch its details.
    3. Use Python script to automate the process that retrieves all dataflows in the workspace, fetches the enhanced compute engine status for each dataflow and print the results.

    Example:

    import requests

    workspace_id = "YOUR_WORKSPACE_ID"

    access_token = "YOUR_ACCESS_TOKEN"

    dataflows_url = f"https://api.powerbi.com/v1.0/myorg/groups/{workspace_id}/dataflows"

    headers = {

        "Authorization": f"Bearer {access_token}",

        "Content-Type": "application/json"

    }

    response = requests.get(dataflows_url, headers=headers)

    dataflows = response.json().get('value', [])

    results = []

    for dataflow in dataflows:

        dataflow_id = dataflow['id']

       

       

        details_url = f"https://api.powerbi.com/v1.0/myorg/groups/{workspace_id}/dataflows/{dataflow_id}"

        details_response = requests.get(details_url, headers=headers)

       

        if details_response.status_code == 200:

            details = details_response.json()

            results.append({

                "dataflow_id": dataflow_id,

                "name": dataflow["name"],

                "enhancedComputeEngine": details.get("enhancedComputeEngine")

            })

        else:

            print(f"Failed to get details for dataflow {dataflow_id}")

    for res in results:

        print(f"Dataflow: {res['name']} (ID: {res['dataflow_id']}) → Enhanced Compute Engine: {res['enhancedComputeEngine']}")

    1. You need to authenticate using OAuth 2.0. Use an endpoint to obtain a Bearer token. Example:

    POST https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token.

    Pass the token in the header for all API calls:

    Authorization: Bearer {access_token}

    1. Make sure your app or service principal has required API permissions like Dataflow.Read.All & Dataflow.ReadWrite.All

    Please refer below documentation for more details:

    Dataflows

    Generate an embed token

     

    If this helped solve the issue, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details, always happy to help.
    Thank you.

  • v-hashadapu's avatar
    v-hashadapu
    1 year ago

    Hi SakethPatchava , Thank you for reaching out to the Microsoft Community Forum.

     

    1. To call the Power BI REST API, you must authenticate using OAuth 2.0. This involves obtaining an access token from Microsoft’s identity platform (Azure AD).

    When you make a call to the Power BI REST API, Microsoft requires you to authenticate first. The Bearer token is like a digital key that proves your identity. You include this token in the Authorization header of each API call.

     

    To get the Bearer Token, one needs to register an Application in Azure Active Directory, get necessary credentials, create a Client Secret, grant API Permissions and Once your app is registered and permissions are granted, you can generate a token by making a POST request to the OAuth 2.0 token endpoint. OAuth 2.0 Token Endpoint: POST https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token

     

    When making API calls to Power BI, you need to include specific headers in your request. The header contains metadata about the request, such as the authentication token, the content type, and sometimes additional configuration details. Example: Content-Type: application/x-www-form-urlencoded

     

    Example of Python Code to Get a Token:
    import requests

    tenant_id = "YOUR_TENANT_ID"

    client_id = "YOUR_CLIENT_ID"

    client_secret = "YOUR_CLIENT_SECRET"

    token_url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token"

    data = {

        "grant_type": "client_credentials",

        "client_id": client_id,

        "client_secret": client_secret,

        "scope": "https://api.powerbi.com/.default"

    }

    response = requests.post(token_url, data=data)

    if response.status_code == 200:

        access_token = response.json().get("access_token")

        print("Access Token:", access_token)

    else:

        print("Failed to retrieve token:", response.text)

     

    Once you have the token, you include it in the request header for all API calls. Example of Calling the Power BI REST API with the Token:

    headers = {

        "Authorization": f"Bearer {access_token}",

        "Content-Type": "application/json"

    }

                 workspace_id = "YOUR_WORKSPACE_ID"

    api_url = f"https://api.powerbi.com/v1.0/myorg/groups/{workspace_id}/dataflows"

    response = requests.get(api_url, headers=headers)

    if response.status_code == 200:

        print("Dataflows:", response.json())

    else:

        print("Failed to retrieve dataflows:", response.text)

     

    1. Fifth point is basically granting all required API Permissions, which is needed in getting bearer tokens. Here is how to do it:

    In the Azure Portal, go to your Azure Portal -> Azure Active Directory -> App Registration -> Select your app -> API Permissions -> Add a Permission -> Power BI Service -> Select Dataflow.Read.All, Dataflow.ReadWrite.All -> Add Permissions -> Grant Admin Consent.

     

    If this helped solve the issue, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details, always happy to help.
    Thank you.

8 Replies

  • Hi SakethPatchava  - Below resources should provide you with the necessary information to manage and retrieve details about the Enhanced Compute Engine for your dataflows using the Power BI REST API.

     

    Premium features of dataflows - Power BI | Microsoft Learn

    Chris Webb's BI Blog: Power BI Dataflow Performance, Premium Per User And The Enhanced Compute Engine

    Dataflows - REST API (Power BI Power BI REST APIs) | Microsoft Learn

    What is a Dataflow Transaction in Power BI | Orchestra

     

    Hope this helps.

  • v-hashadapu's avatar
    v-hashadapu
    Community Support

    Hi SakethPatchava , Please let us know if your issue is solved. If it is, consider marking the answer that helped 'Accept as Solution', so others with similar queries can find it easily. If not, please share the details.
    Thank you.

      • v-hashadapu's avatar
        v-hashadapu
        Community Support

        Hi SakethPatchava , Thank you for reaching out to the Microsoft Community Forum.

        To retrieve the Enhanced Compute Engine details for a specific dataflow and for all dataflows in a Power BI workspace using the Power BI REST API, follow these steps:

        1. For a specific Dataflow, use Rest API Endpoint. Example: GET https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/dataflows/{dataflowId}. The enhancedComputeEngine property in the response indicates whether the Enhanced Compute Engine is enabled.
        2. To get the Enhanced Compute Engine details for all dataflows, First, retrieve all dataflows in the workspace. Example: GET https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/dataflows. Then, loop through each dataflow and call the first endpoint to fetch its details.
        3. Use Python script to automate the process that retrieves all dataflows in the workspace, fetches the enhanced compute engine status for each dataflow and print the results.

        Example:

        import requests

        workspace_id = "YOUR_WORKSPACE_ID"

        access_token = "YOUR_ACCESS_TOKEN"

        dataflows_url = f"https://api.powerbi.com/v1.0/myorg/groups/{workspace_id}/dataflows"

        headers = {

            "Authorization": f"Bearer {access_token}",

            "Content-Type": "application/json"

        }

        response = requests.get(dataflows_url, headers=headers)

        dataflows = response.json().get('value', [])

        results = []

        for dataflow in dataflows:

            dataflow_id = dataflow['id']

           

           

            details_url = f"https://api.powerbi.com/v1.0/myorg/groups/{workspace_id}/dataflows/{dataflow_id}"

            details_response = requests.get(details_url, headers=headers)

           

            if details_response.status_code == 200:

                details = details_response.json()

                results.append({

                    "dataflow_id": dataflow_id,

                    "name": dataflow["name"],

                    "enhancedComputeEngine": details.get("enhancedComputeEngine")

                })

            else:

                print(f"Failed to get details for dataflow {dataflow_id}")

        for res in results:

            print(f"Dataflow: {res['name']} (ID: {res['dataflow_id']}) → Enhanced Compute Engine: {res['enhancedComputeEngine']}")

        1. You need to authenticate using OAuth 2.0. Use an endpoint to obtain a Bearer token. Example:

        POST https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token.

        Pass the token in the header for all API calls:

        Authorization: Bearer {access_token}

        1. Make sure your app or service principal has required API permissions like Dataflow.Read.All & Dataflow.ReadWrite.All

        Please refer below documentation for more details:

        Dataflows

        Generate an embed token

         

        If this helped solve the issue, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details, always happy to help.
        Thank you.

  • v-hashadapu's avatar
    v-hashadapu
    Community Support

    Hi @SakethPatchava , Please let us know if your issue is solved. If it is, consider marking the answer that helped 'Accept as Solution', so others with similar queries can find it easily. If not, please share the details.
    Thank you.

  • v-hashadapu's avatar
    v-hashadapu
    Community Support

    Hi @SakethPatchava , We are closing this thread as we haven't heard from you in a while, according to our follow-up policy. If you have any more questions, please start a new thread on the Microsoft Fabric Community Forum. We will be happy to assist you! Thank you for being part of the community!