Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi Guys
I wanted to share information about the automation of importing PowerBI audit logs using Application Permissions from PowerBI service right from App registration to using MSAL python library.
Since most of the company's we use multifactor authentication, delegated permissions will not allow any python/.net application to get automated.
The first thing we need to perform is registering an app in Azure portal or using app registration using following link https://dev.powerbi.com/apps
App Registration:
Perform app registration steps only as mentioned in the following blog (https://carldesouza.com/how-to-register-an-azure-app-to-use-with-power-bi/) and DO NOT set any permissions. Since these permissions didn't work while authenticating the token generated.
Permissions:
https://docs.microsoft.com/en-us/power-bi/admin/read-only-apis-service-principal-authentication
Making API calls using MSAL library:
{ "authority": "https://login.microsoftonline.com/Enter you tenantID Here ",
"client_id": "Enter ClientID of the app you have Registered",
"scope": ["https://analysis.windows.net/powerbi/api/.default"],
"secret": "Enter Client Secret you created above",
"endpoint": "https://api.powerbi.com/v1.0/myorg/admin/groups?$expand=datasets,dataflows,reports,dashboards,users&..."
}
Note: There might be better ways to program in Python to extract the data from these API's but this is what I have developed which is working successfully.
Hi @Anonymous ,
Good idea. You can tag your own answers to the solution so that more people can see it and so you can help more people.
Best Regards
Lucien