Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Programatically start/stop Azure PowerBI capacity for PowerBI Embedded

With the new start/stop capacity options on Azure for PowerBI, can I start and stop the capacity from a .net app or powershell?

I understand that I can pause capacity in the Azure Portal, but would like to be able to pause/start capacity using an API call.

23 Replies

  • ckelbley's avatar
    ckelbley
    Frequent Visitor

    I have had success using these API calls:

     

    POST https://management.azure.com/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP_NAME/providers/Microsoft.PowerBIDedicated/capacities/CAPACITY_NAME/resume?api-version=2017-10-01
    POST https://management.azure.com/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP_NAME/providers/Microsoft.PowerBIDedicated/capacities/CAPACITY_NAME/suspend?api-version=2017-10-01

     

    • Eric_Zhang's avatar
      Eric_Zhang
      Microsoft Employee

      ckelbley wrote:

      I have had success using these API calls:

       

      POST https://management.azure.com/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP_NAME/providers/Microsoft.PowerBIDedicated/capacities/CAPACITY_NAME/resume?api-version=2017-10-01
      POST https://management.azure.com/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP_NAME/providers/Microsoft.PowerBIDedicated/capacities/CAPACITY_NAME/suspend?api-version=2017-10-01

       


      ckelbley

      Could you share where you find those APIs, any documentations?

      • ckelbley's avatar
        ckelbley
        Frequent Visitor

        I couldn't find any official documentation.  I just did some trial and error using Postman and tried different calls based on how the management APIs work for other resource types and looking at what the browser does when you click the pause/start button in the Azure portal.

  • Eric_Zhang's avatar
    Eric_Zhang
    Microsoft Employee

    Anonymous wrote:

    With the new start/stop capacity options on Azure for PowerBI, can I start and stop the capacity from a .net app or powershell?

    I understand that I can pause capacity in the Azure Portal, but would like to be able to pause/start capacity using an API call.


    Anonymous

    There might be. The legency documentation is not updated. I'm going to consult this internally and would post back if there comes any update.

  • Was the availability of this API to pause/resume capacity announced on the Power BI blog?

     

    It would be great if the team could communicate the addition of these features!

  • Hi all,

    Each new feature or addition we release is being announced in the monthly developer update for Power BI.

    Be sure to follow up there for all new additions.

     

    I'm troubled to hear about the pitfalls you are encountering.

    To get started, use this documentation and follow the steps described there- https://docs.microsoft.com/en-us/power-bi/developer/embedding

     

    I would be happy to hear more on specific problems you faced and what you think should be the solution.

     

    Thanks,

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Nimrod.

      If you have the time; these are the potential pitfalls (and I think I stumbled on every single one):

      Your link doesn't help much for most ISV users since I'ts in C#. We use MEAN stack for instance
      I prefer the API POST/GET method since It Isn't code language dependant.

      Problems

      Microsoft login (Both Azure and Power BI).
      The old login experience took into account that you always want to choose your account type edu/work/personal upon login.
      The new MS login is flawed in some ways:

      • Creates new accounts by asking for new password, so now I have 2 Azure accounts unwillingly.
      • Creates Azure accounts based on your Outlook email being open.
      • Blocks email client from working If you logged into azure before outlook.
      • No security feature per users, stay logged in however long you like, admin can be logged into many browsers and computers at the same time. This is not very safe for being a corporate service.
      • Solution: Azure session timer. Always show "choose type of account Edu/work/personal". Don't allow multi login for Azure admins, kick out from other session.

      Azure account type
      Your tech support did not know the prerequisit for Azure to allow access to resources - SKU or workspaces.

      This led to:

      • Azure allowed account creation with @hotmail.com accounts.
      • Coorporate emails wont be recognized and thus creating Azure personal accounts.
      • There was no information atleast not within the pages concerning Power BI embedded; that Domain DNS had to be registered within Office 365 and Cloudflare of your company domain to allow full Azure functionality.
      • Solution: block Azure from certain email suffixes. Link clearly step by step guide of how to take over domain in Office 365, you have docs on this just link it to the step by step guide for Power bi embedded.

      Power BI embedded docs

      • After knowing that changes to Embedded service would happen after July 2017 (scarse messages from MS in forums and some guy in the cube videos) there was still no documentation at all regarding Power BI SKU at november 2017.
      • No links to ARM for starting/pausing the service a vital API command for this new running cost service.
      • API documentation on Azure ARM and PBI API does not have any information of what request header and credentials are needed to get a Bearer token OR an Embed token for your report.
      • I have now searched half day after a connection documentation for PBI embedded. I'm guessing many will want to automate creation of reports and app workspaces. I want to use a report as template and populate this with new customer data. Are there any new connectors that the API could use besides Streaming JSON, MS SQL, SPARK, xlsx and CSV?
      • Add Product Portfolio overview. Power BI product line is getting more diffuse. Please explain capabilities and prices for all products in a matrix chart. For instance that dashboards doesnt exist in PBI desktop, data sources and measures can't be edited in PBI cloud. Dashboards can't be themed and can't crossfilter. PBI premium capabilities vs PBI embedded.
      • Solution: Delete your old docs, or atleast put a "notice of depricated service" on all old docs. Add new docs for SKU method. Include links under "How to embed"; to github for more languages, ARM API & Power BI API. Include the Headers needed for successful API calls. Update info about dataset switching and sources supported, the old Workspace collection method was more limited but I haven't seen any proof that more datasources are supported.
      • nimrod's avatar
        nimrod
        Resolver II

        Thanks for the thorough feedback. 

        It is important for us to hear your problems and suggestions.

        While some of the bullets are not related directly to PBI, we will try to pass it forward.

         

        Adding some notes to the last part:

        Power BI embedded docs

        • After knowing that changes to Embedded service would happen after July 2017 (scarse messages from MS in forums and some guy in the cube videos) there was still no documentation at all regarding Power BI SKU at november 2017.

        We have a monthly blog with all updates. See the relevant onehttps://powerbi.microsoft.com/en-us/blog/power-bi-embedded-capacity-based-skus-coming-to-azure/

        • No links to ARM for starting/pausing the service a vital API command for this new running cost service.

        It's still pretty new. Again, you can find it through our monthly blog post. Here is what you are looking forhttps://docs.microsoft.com/en-us/rest/api/power-bi-embedded/

        • API documentation on Azure ARM and PBI API does not have any information of what request header and credentials are needed to get a Bearer token OR an Embed token for your report.\

        We will look into it.

        • I have now searched half day after a connection documentation for PBI embedded. I'm guessing many will want to automate creation of reports and app workspaces. I want to use a report as template and populate this with new customer data. Are there any new connectors that the API could use besides Streaming JSON, MS SQL, SPARK, xlsx and CSV?

        Starting June 2017, PBI Embedded supports all of the data sources that Power BI supports. The API itself can support SQL Azure/On-prem and AS Azure/ On-prem in all relevant connections. See November blog posthttps://powerbi.microsoft.com/en-us/blog/power-bi-developer-community-november-update/

        • Add Product Portfolio overview. Power BI product line is getting more diffuse. Please explain capabilities and prices for all products in a matrix chart. For instance that dashboards doesnt exist in PBI desktop, data sources and measures can't be edited in PBI cloud. Dashboards can't be themed and can't crossfilter. PBI premium capabilities vs PBI embedded.

        Thanks for the feedback, we will look into it

  • leo1's avatar
    leo1
    New Member

    Hello guys,

     

    Anyone discover any way to schedule an stop for Power BI Embedded?

    • jimmcslim's avatar
      jimmcslim
      Helper III

      wrote:

      Anyone discover any way to schedule an stop for Power BI Embedded?


      This is pretty straightforward... create a Powershell script that you can use within an Azure Automation runbook. This Powershell script should use the latest version of the Azure RM Powershell module that the Power BI team have added pause/resume capacity commands to. Then you schedule the runbook to run at the appropriate time of day/day of week.

       

      It is probably easiest to create two separate runbooks; one for pausing, one for resuming - but you could add parameters to your script/runbook and handle both situations in the one script. Plus you might want to add parameters to indicate which capacity to pause/resume or maybe just hard-code this if appropriate.

       

      It appears that the capacities pause and resume pretty quickly - but that might depend on time of day/region/capacity size, etc. Any insight from the Power BI team here would be great!

      • Nikhilkumar6212's avatar
        Nikhilkumar6212
        Regular Visitor

        Perhaps you can use "Azure Automation runbook" ? to pause/resume your embedded capacities

  • rshahrabani's avatar
    rshahrabani
    Frequent Visitor

    Hi,

     

    I'm trying to start/stop Azure Power BI Embedded capacity using the REST API, but it is returning Unauthorized.

     

    When executing the Capacities - Resume API at https://docs.microsoft.com/en-us/rest/api/power-bi-embedded/capacities/resume#code-try-0, it runs successfully, but when I run the same code (see below) in a .NET application it returns an Unauthorized error.

     

    The difference between the application call and the REST API Try It is the access token.  If I use the access token generated at the url above in the application, it runs successfully, but if I use the access token that I obtained using the Power BI .NET SDK, then it fails with the Unauthorized error.

     

    Please help, stuck on this problem for a long time.

     

    Thanks,

    Ronny

     

    Code:

    ------

     

    POST https://management.azure.com/subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.PowerBIDedicated/capacities/<capacity_name>/resume?api-version=2017-10-01

    Authorization: Bearer <access_token>

    Content-type: application/json