Using Power BI REST API:
-
Set Up Azure AD App: Register an app in Azure AD for authentication and get the Client ID and Tenant ID.
-
Get Access Token: Use OAuth2 to get an access token.
-
Call API to Create Workspace: Send a POST request to https://api.powerbi.com/v1.0/myorg/groups with workspace details:
{
"name": "NewWorkspaceName",
"description": "Workspace description"
}
-
Automate: Use scripts (Python, C#, etc.) to handle token retrieval and API calls.
Using PowerShell:
-
Install Power BI Module: Run Install-Module -Name MicrosoftPowerBIMgmt.
-
Authenticate: Use Connect-PowerBIServiceAccount to log in.
-
Create Workspace: Run:
New-PowerBIWorkspace -Name "New Workspace" -Description "Workspace description"
4. Automate: Write PowerShell scripts for batch creation.
Both methods allow you to automate workspace creation with security and logging best practices.