Automatically Pause PBI Embedded Capacity using Power Automate — Flow
I often use Embedded Power BI to test the fun stuff reserved to Premium users; I also warn my colleagues that use this capacity to remember turning it off as it becomes quite expensive to leave it on; well I left running the thing for two weeks.
How to avoid doing the same stupid mistake
After confessing my sin to my boss, and being thankful for not being killed I started investigating how to programmatically avoid doing knucklehead stuff; fortunately, we live in a world with APIs and Power Automate.
For doing this we will need to:
1) Register an app in Azure
2) Modify the App
3) Create a custom connector in Flow
4) Create a flow
1. Registering an app the lazy way
Application type = Server side web application
Home page URL = https://www.powerbi.com
Redirect URL = https://www.powerbi.com
Select only one option in API, it is not relevant, click on “Register,” after doing this, your Application ID and Secret will appear, copy them.
2. Modify the App
Go to the address below and select the app you just registered.
Once in there, go to the authentication section and modify the URI’s to the following:
If you ever lose your “Application ID” or “Client Secret” you can get them at “Overview” or “Certificates and Secrets”, be aware that the secret can not be retrieved, you need to create a new one.
Next, in “API Permissions” you have to add the “Azure Service Management” permission of “user impersonation.”
3. Create a custom connector.
Let’s head to https://flow.microsoft.com/ and here create a custom connector from blank.
General: The first section refers to the name and description of the connector.
Security: Fill as shown below
The steps here are, (1) create a new action, (2) description and name of the action, (3) click on “import from sample,” then do not forget to (4) select “Post”, paste the following URL (5):
Finally, we must click in import (6):
Test the connector
To test the connector, first, you will need to provide your credentials (1), then fill in the information of the parameters in the API, the person that created the capacity should be able to go to Portal Azure and get this information.
4. Create a flow that suspends the capacity.
I know I can do the flow more sophisticated, but I wanted something quick no matter if it was dirty, so every six hours the flow goes and suspend the capacity. The second step is from the custom connector we created.
Well I hope you like it, please let me know if you would like me to expand on any of the steps.
The blog below was super useful to figure out this one.
Leverage Power BI Automation Using Power Automate and API
Introduction For a Power BI tenant's administrator, it's a challenging task to admin and maintain the environment. Many…
And here is the Microsoft related documentation.