Microsoft Azure Power BI Embedded Management Client Library for Python
This is the Microsoft Azure Power BI Embedded Management Client Library for Python, providing client-side functionality to manage Power BI Embedded workspace collections and retrieve workspaces within an Azure subscription. The library is currently at version 3.0.0 and follows the Azure SDK release cadence, with updates typically driven by new features or breaking changes in the underlying Azure API.
Warnings
- breaking Version 3.0.0 introduced significant breaking changes to the credential system. Old `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported. The `credentials` parameter has been renamed to `credential`.
- breaking Version 2.0.0 changed model signatures to use keyword-only arguments. Positional arguments for models must be rewritten as keyword arguments.
- gotcha Proper Azure Active Directory (AAD) application setup is crucial. Authentication requires setting specific environment variables (`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_SUBSCRIPTION_ID`). Additionally, the service principal often needs specific Power BI API permissions and role assignments in the Power BI service or workspace, not just general Azure 'Owner' roles.
- deprecated The concept of 'Power BI Embedded workspace collections' (A SKUs) has largely been superseded by 'Power BI Embedded Generation 2' and 'Fabric F SKUs'. While the management client might still exist for older resources, new deployments are encouraged to use Fabric capacities.
Install
-
pip install azure-mgmt-powerbiembedded -
pip install azure-identity
Imports
- PowerBIEmbeddedManagementClient
from azure.mgmt.powerbiembedded import PowerBIEmbeddedManagementClient
- DefaultAzureCredential
from azure.identity import DefaultAzureCredential
Quickstart
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.powerbiembedded import PowerBIEmbeddedManagementClient
# Set environment variables for authentication and subscription ID:
# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET (for service principal)
# AZURE_SUBSCRIPTION_ID
# For local development, DefaultAzureCredential will try various methods (env vars, managed identity, VS Code, Azure CLI, etc.)
credential = DefaultAzureCredential()
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "")
if not subscription_id:
raise ValueError("AZURE_SUBSCRIPTION_ID environment variable is not set.")
client = PowerBIEmbeddedManagementClient(credential=credential, subscription_id=subscription_id)
# Example: List Power BI Embedded workspace collections (replace with actual operation)
# This is a placeholder as Power BI Embedded workspace collections are largely deprecated
# and modern Power BI embedding relies on other APIs or Fabric capacity.
# The management library is for managing the *Azure resource* itself, not the Power BI content.
# For Power BI content interaction, refer to Power BI REST APIs and SDKs.
# https://learn.microsoft.com/en-us/rest/api/power-bi/
# The Power BI Embedded A SKUs were deprecated in favor of Fabric F SKUs.
# The management client would typically manage resources like capacity or workspace collections.
# As workspace collections are deprecated, direct management with this client for new scenarios is less common.
# For illustrative purposes, an older operation might look like:
# collections = client.workspace_collections.list_by_resource_group(resource_group_name="myResourceGroup")
# for collection in collections:
# print(collection.name)
print("PowerBIEmbeddedManagementClient initialized. Operations may vary based on current Azure API status.")