cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
amklauck
Regular Visitor

Resume/suspend PowerBI embedded capacity with REST API via Custom Connector

Hello there! I've created a custom connector that sends a https request (post) using the Power BI Embedded api documented in here: https://docs.microsoft.com/pt-br/rest/api/power-bi-embedded/

When I test the connector while editing it, everything works fine and I get a 202 response, successfully suspending or resuming my capacity. I tried to build a flow to suspend (and one to resume) my capacity in a daily frequency using my custom connector and when I test it I get an error response "404, resource not found", causing the flow to stop at this point - however, when I check my embedded resource, the flow DOES SUSPEND/RESUME as supposed.

What am I missing here? My flow consists in calling the custom connector action after checking today's weekday (suspends the capacity between 10 pm and 4 am and on the weekend) and sending me an email (which never occurs, since it always crashes).

These are the inputs:

{
    "host": {
        "connectionReferenceName""shared_pbiembeddedconnector-<some-id>",
        "operationId""ControleCE"
    },
    "parameters": {
        "subscriptionId": mySubID,
        "resourceGroupName": myResourceGroupName,
        "dedicatedCapacityName"myCapacityName,
        "action""suspend",
        "api-version""2021-01-01"
    }
}
 
And these are the outputs:
Body:
{
  "statusCode"404,
  "message""Resource not found"
}
 
Header:
{
  "Access-Control-Allow-Methods""GET, PUT, PATCH, DELETE, POST",
  "Access-Control-Allow-Origin""*",
  "Access-Control-Max-Age""3600",
  "Access-Control-Expose-Headers""*",
  "Date""Fri, 29 Jul 2022 16:31:05 GMT",
  "Content-Length""54",
  "Content-Type""application/json"
}

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
cowg843
Frequent Visitor

Hi, 

I had exactly the same issue, I had a custom connector setup to switch an embedded capacity on/off. It worked within test but when including it in a Power Automate flow, it showed as failed (despite the capacity starting or being paused).

I believe I have found a solution. 

In the settings of the action for the connector in Power Automate, change the setting for asynchronous pattern to false. 

cowg843_0-1669206432940.png

 

I did this and changed nothing else, but the action now shows as successfully completed. 

Hope that resolves your issue.

View solution in original post

8 REPLIES 8
soleary
Regular Visitor

Hi @amklauck, I have the exact same issue.  I created a custom connector, tested it, and it works.  When I add it to a flow, it fails with the same message.  Like yours, it actually completes the POST request successfully and resumes or suspends the SKU.  Did you find a resolution or workaround for your solution?

 

OUTPUTS

{
    "statusCode"404,
    "headers": {
        "Access-Control-Allow-Methods""GET, PUT, PATCH, DELETE, POST",
        "Access-Control-Allow-Origin""*",
        "Access-Control-Max-Age""3600",
        "Access-Control-Expose-Headers""*",
        "Date""Mon, 07 Nov 2022 22:36:47 GMT",
        "Content-Length""54",
        "Content-Type""application/json"
    },
    "body": {
        "statusCode"404,
        "message""Resource not found"
    }
}

Hi there @soleary! Unfortunately I couldn't find a resolution to this issue. I gave up using Power Automate and managed to achieve what I wanted using runbooks (Powershell Workflow) on an automation account inside the Azure Portal. I don't know if you are familiar to it (I wasn't back then), but I found it much more reliable than Power Automate. You can find a starting guide in here: https://www.flip-design.de/?p=730

Thank you very much, @amklauck!  I've used PowerShell, but not Azure Automation Runbooks.  Agreed, this looks like a better option.  I will check this out...thanks for the quick reply and the tip!

cowg843
Frequent Visitor

Hi, 

I had exactly the same issue, I had a custom connector setup to switch an embedded capacity on/off. It worked within test but when including it in a Power Automate flow, it showed as failed (despite the capacity starting or being paused).

I believe I have found a solution. 

In the settings of the action for the connector in Power Automate, change the setting for asynchronous pattern to false. 

cowg843_0-1669206432940.png

 

I did this and changed nothing else, but the action now shows as successfully completed. 

Hope that resolves your issue.

Hi @cowg843!
Thank you for you response!  I got it working using a couple API calls, one to get a token and then one to turn the capacity on/off.  However, the custom connector is more reusable and a little more friendly for the users that aren't familiar with API calls.  I will definitely give this a try!  Thanks very much for the tip!

Thank you @cowg843! My solution with the runbooks is running very well, but I gave a try with my old Power Automate flow and the change of settings you mentioned. It worked like a charm! Hopefully it will help other users from now on, thanks.

reubenanderson
New Member

Hey, 

 

Found this issue as well. Like the solution says, I can get around it by disabling Async flow... but I kind of what to do better than that. I want it to email me when either; 

- the service was running and is now shutdown

- there was some other unexpected error. 

 

And I want it to not email me if the service was already shutdown. 

 

I figure, I should be able to check whether it's running.. and then fire the suspend... rather than trying to suspend it and getting an 'expected' error. 

 

And also.. like... a 202 is the correct response for an async process... so.. this should just work eh. 

 

 

reubenanderson
New Member

... actually, yeah, it does work if you; 

 

1. create a second custom connector that checks the state of a power bi embedded capacity. 

https://learn.microsoft.com/en-us/rest/api/power-bi-embedded/capacities/get-details?tabs=HTTP

It's basically the same rest API, but you need a second connector as this uses a GET rather than a POST 

 

2. Have your Flow app check the state first - call the GET, parse the result.. proceed to stop depending on whether the provisioningState is "Paused". 

 

Mine now works a treat. 

 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (3,842)