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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
lese
New Member

Resume and suspend powerbi capacity programmatically

Developing Power bi embedded web-app written in django (python). I retrive workspace, dashboards and report successfully, I also get capacity informations against azure portal , all this by using access token retrived in the following way (using adal python module):

def azure_auth():
    context = adal.AuthenticationContext(
        settings.PBI_AUTHORITY,
        validate_authority=True,
        api_version=None)

    token_response = context.acquire_token_with_username_password(
        settings.PBI_RESOURCE,
        settings.PBI_USERNAME,
        settings.PBI_PASSWORD,
        settings.PBI_CLIENTID
    )

    aad_token = token_response['accessToken']

    headers = {'Authorization': 'Bearer ' + aad_token}

    return headers
subsequently i use the retrieved token to make the various requests and they al work fine, the following works fine too, witch it is similar (from a permission point view) to the requests that i'm unable to perform (resume / suspend capacity):
def get_capacities(headers):
    capacities_request = requests.get(
        "https://api.powerbi.com/v1.0/myorg/capacities", headers=headers)

    print("HTTP response:" + str(capacities_request))

    obj = json.loads(capacities_request.text)
    print("capacities: \n" + str(obj))
But resuming capacity as following fail with a 401 Unauthorized http error code: 
def resume_pbi_capacity(headers):
  response = requests.post('https://management.azure.com/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP_NAME/providers/Microsoft.PowerBIDedicated/capacities/CAPACITY_NAME/resume?api-version=2017-10-01', headers)
  print(response)
I may use a different method to retrieve the token? 
 
reading here I have corrected the permissions (Access control (IAM)) into Azure portal to allowing the user that the application use to perform suspend /resume operations, but it does not seems to be enough
 
 
How to retrive token to perform suspend / resume capacity operations? 
0 REPLIES 0

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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