Permission issue while calling the PowerBI API from Azure Data Factory

Anonymous
2022-02-03T07:17:56.86+00:00

PowerBI API works well when i use the bearer token issued from doc.micosoft.com(Try it) in Azure data factory, but it expires after a while so i have to change the bearer token again to run the pipeline.

![170864-image.png]2

170759-image.png

However, when i am generate the bearer token from Azure Data Factory and use it for PowerBI API permission, it fails with an unauthorized error message.

Following are the steps which I used in Azure data factory to create bearer token :-

1) App Registration of PowerBI in AAD with secret
2) Create a pipeline and bring in the Web activity to get a token.
a. Use the URL https://login.microsoftonline.com/\<Tenant ID>/oauth2/token
b. POST method
c. Add a new Header with the name of Content-Type and Value of application/x-www-form-urlencoded
d. In body added :-
tenant=tenantid&client_id="client or Application ID from App registration"&client_secret="client Secret from App registration"&grant_type=client_credentials&scope=https://analysis.windows.net/powerbi/api/.default

170834-image.png

i am able to successfully construct the bearer token by following steps 2 .

3) Assign access token to a variable.
4) And on second web activity we are using the bearer token for authorization of PowerBI API.
a. Use the URL https://api.powerbi.com/v1.0/myorg/groups/\<groupid>/datasets/<datasetid>/refreshSchedule
b. GET Method
c. Add a new Header with the name of Authorization and Value of @markus.bohland@hotmail.de ('Bearer ',variables('token')).

170872-image.png

The bearer token was not authorized on the second web activity.

if there is a step that i am missing or if there is another way to successfully authorize the PowerBI API token called form ADF?

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
0 comments No comments
{count} votes

Answer accepted by question author
  1. ShaikMaheer-MSFT 38,556 Reputation points Microsoft Employee Moderator
    2022-02-04T14:51:58.833+00:00

    Hi @Anonymous ,

    Thank you for posting query in Microsoft Q&A Platform.

    From the error message it seems you don't have permission to PowerBI. We must have request permission.

    Kindly check below post which helps to get required permissions for PowerBI.
    https://www.moderndata.ai/2019/05/powerbi-dataset-refresh-using-adf/

    Hope this will help. Please let us know how it goes. Thank you.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.