Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mbertho
New Member

How to schedule Pause/Stop BI Resource embedded automatically

Hello,

I am trying to configure the start/stop Power BI Embedded resource using web insterface, it is running with succesfull(by reports inside powerBI) but don't is pausing/starting my Power BI resource(it doesn't works).

 

Informations:
Type: Power BI Embedded
Localization: "Brazil South"

*Not exists the resource start/stop avaliable for my localization(Brazil), i used from localization Canada.

 

How the easy way to do it, i prefer some API to program this opition, but i saw the some APIs and didn't find this resource.
Somebody did it and could post some example, please ?

 

Regards,
Marcelo Bertho

 

 

2 REPLIES 2
v-ljerr-msft
Employee
Employee

Hi @mbertho,

 

Just check this blog. Smiley Happy

Azure Resource Manager API

The release of the new Azure capacities for Power BI Embedded in October enables ISVs to enjoy the full elasticity of an Azure resource. ISVs can now pause or resume capacity, scale up or down and pay for hourly usage only. To fully leverage this capability, those actions need to occur programmatically.

So now, as promised, we are releasing Azure Resource Management APIs to do all these actions automatically. These are all the actions you can perform using the ARM API:

  • Scale up/ down
  • Pause/ start resource
  • Create/ Delete resource
  • Get capacity information
  • Update capacity
  • Get capacity list in a resource group/ subscription

Here are some code samples you can use:

Scale up/ down:

string content = "{\"sku\":{\"name\":\"" + "{Enter new sku for scaling}" + "\"}}";

ASCIIEncoding encoding = new ASCIIEncoding();

byte[] contentArray = encoding.GetBytes(content);

string requestUri = "https://management.azure.com/subscriptions/{Enter subscriptionId}/resourceGroups/{Enter resourceGrou...";

HttpWebRequest request = System.Net.WebRequest.Create(requestUri) as System.Net.HttpWebRequest;

            request.Method = "PATCH";

            request.Headers.Add("Authorization", String.Format("Bearer {0}", accessToken));

            request.ContentType = "application/json; charset=utf-8";

            request.ContentLength = contentArray.Length;

Stream stream = request.GetRequestStream();

            stream.Write(contentArray, 0, contentArray.Length);

            stream.Close();

HttpWebResponse response = request.GetResponse() as HttpWebResponse;

Pause:

string requestUri = "https://management.azure.com/subscriptions/{Enter subscriptionId}/resourceGroups/{Enter resourceGrou...";

HttpWebRequest request = System.Net.WebRequest.Create(requestUri) as System.Net.HttpWebRequest;

            request.Method = “POST”;

            request.ContentLength = 0;

            request.Headers.Add("Authorization", String.Format("Bearer {0}", accessToken));

HttpWebResponse response = request.GetResponse() as HttpWebResponse;

Start:

string requestUri = "https://management.azure.com/subscriptions/{Enter subscriptionId}/resourceGroups/{Enter resourceGrou...";

HttpWebRequest request = System.Net.WebRequest.Create(requestUri) as System.Net.HttpWebRequest;

            request.Method = “POST”;

            request.ContentLength = 0;

            request.Headers.Add("Authorization", String.Format("Bearer {0}", accessToken));

HttpWebResponse response = request.GetResponse() as HttpWebResponse;

 

You can download the full ARM SDK from GitHub, or learn more from our documentation.



 

Regards

Hi v-ljerr-msft,

 

Firstly, thanks for your reply.

 

I am studying your post and did some tests, but i don't know how i get the access token:

 

curl -d "" -H "Authorization:Bearer <TOKEN>" -X POST "https://management.azure.com/subscriptions/<myid>/resourceGroups/BI/providers/Microsoft.PowerBIDedic..."
{"error":{"code":"InvalidAuthenticationToken","message":"The access token is invalid."}}%

 

Where could i get the token ?

 

*My idea is create a jenkins job and schedule for it using the command that you passed in the earlier reply.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.