Power Automate and Power BI Rest API
The Power BI rest api provides the ability to create a workspace. Power Automate includes an action to make a HTTP call, i.e. a rest api. So we should be able to get a flow to create a workspace. So that was my goal. Writing the first flow and getting it to work involved so many little steps I had to write blog posts so I would remember the steps.
Power BI Rest API Documentation
The documentation refers to workspaces as groups and can be found at https://learn.microsoft.com/en-us/rest/api/power-bi/groups/create-group. It states that the API can be called by a service principal profile and the required scope is Workspace.ReadWrite.All.
Other Settings
You also need to make some changes to Power BI tenant settings as well and I’d recommend creating a security group and using Azure Key Vault to store the credentials. That would make a very long blog post so I’m breaking it down into separate posts.
- Create a Power BI Service Principal Profile
- Create Key Vault to store Tenant ID, Client ID and Secret
- Write a flow to fetch the Key Vault Values
- Update Power BI Settings and Create a Security Group
- Write a flow to create the workspace
- Extras for the workspace
Final Power Automate Flow
The final flow, after post 5, fetches the Service Principal credentials using a child flow, then uses HTTP action to create the workspace and with a bit of parse json action magic uses another HTTP action to change the permissions.
The above flow has flaws, no error handling, no checking the workspace name is allowed and no notifying the admin they have a new workspace.
Next Steps
This is a simple example of using Power Automate with Power BI rest API to perform some admin tasks. This could easily be extended to include other boring admin tasks.
1 Response