Power BI Deployment Pipelines CheatSheet 1731972155
This cheat sheet provides a comprehensive guide to Power BI Deployment Pipelines, including REST API operations, PowerShell commands, Azure DevOps pipeline YAML commands, Git commands, and CLI commands for managing Power BI resources. It also covers best practices for deployment, error handling, logging, and security measures. The document serves as a quick reference for users looking to automate and manage Power BI deployments effectively.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
39 views
Power BI Deployment Pipelines CheatSheet 1731972155
This cheat sheet provides a comprehensive guide to Power BI Deployment Pipelines, including REST API operations, PowerShell commands, Azure DevOps pipeline YAML commands, Git commands, and CLI commands for managing Power BI resources. It also covers best practices for deployment, error handling, logging, and security measures. The document serves as a quick reference for users looking to automate and manage Power BI deployments effectively.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10
# [ Power BI Deployment Pipelines ] CheatSheet
1. Power BI REST API Operations
● Get all pipelines: Invoke-RestMethod -Uri
"https://api.powerbi.com/v1.0/myorg/pipelines" -Headers $headers -Method Get ● Create a pipeline: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines" -Headers $headers -Method Post -Body $pipelineJson ● Get pipeline details: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}" -Headers $headers -Method Get ● Delete a pipeline: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}" -Headers $headers -Method Delete ● Get pipeline stages: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/stages" -Headers $headers -Method Get ● Get pipeline stage: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/stages/{ stageOrder}" -Headers $headers -Method Get ● Get pipeline operations: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/operatio ns" -Headers $headers -Method Get ● Get pipeline users: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/users" -Headers $headers -Method Get ● Add user to pipeline: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/users" -Headers $headers -Method Post -Body $userJson ● Remove user from pipeline: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/users/{u serPrincipalName}" -Headers $headers -Method Delete
2. PowerShell Commands (Power BI Management Module)
● Install Power BI module: Install-Module -Name MicrosoftPowerBIMgmt
● Connect to Power BI service: Connect-PowerBIServiceAccount ● Get Power BI workspaces: Get-PowerBIWorkspace By: Waleed Mousa ● Get Power BI reports: Get-PowerBIReport ● Get Power BI datasets: Get-PowerBIDataset ● Get Power BI dataflows: Get-PowerBIDataflow ● Get Power BI dashboards: Get-PowerBIDashboard ● Export Power BI report: Export-PowerBIReport -Id $reportId -OutFile ".\report.pbix" ● Import Power BI report: New-PowerBIReport -WorkspaceId $workspaceId -Path ".\report.pbix" -ConflictAction CreateOrOverwrite ● Copy Power BI report: Copy-PowerBIReport -Id $reportId -TargetWorkspaceId $targetWorkspaceId -TargetModelId $targetModelId
3. Azure DevOps Pipeline YAML Commands
● Trigger pipeline on main branch: trigger: [main]
● Use Windows VM image: pool: vmImage: 'windows-latest' ● Define pipeline variables: variables: - group: PowerBIDeploymentVariables ● Install Power BI cmdlets: - powershell: Install-Module -Name MicrosoftPowerBIMgmt -Force -Scope CurrentUser ● Authenticate to Power BI: - powershell: Connect-PowerBIServiceAccount -ServicePrincipal -CertificateThumbprint $(CertThumbprint) -ApplicationId $(AppId) -TenantId $(TenantId) ● Export report from dev workspace: - powershell: Export-PowerBIReport -Id $(DevReportId) -OutFile "$(Build.ArtifactStagingDirectory)\report.pbix" ● Publish artifact: - publish: $(Build.ArtifactStagingDirectory) artifact: drop ● Download artifact: - download: current artifact: drop ● Import report to test workspace: - powershell: New-PowerBIReport -WorkspaceId $(TestWorkspaceId) -Path "$(Pipeline.Workspace)\drop\report.pbix" -ConflictAction CreateOrOverwrite ● Update dataset parameters: - powershell: Set-PowerBIDatasetParameter -DatasetId $(TestDatasetId) -ParameterName "ServerName" -ParameterValue "test-server"
● Install Power BI CLI: npm install -g powerbi-cli
● Login to Power BI: pbicli login ● List workspaces: pbicli workspace list ● Get workspace details: pbicli workspace get --workspace-id {workspaceId} ● List reports in workspace: pbicli report list --workspace-id {workspaceId} ● Get report details: pbicli report get --report-id {reportId} ● Export report: pbicli report export --report-id {reportId} --output-file report.pbix ● Import report: pbicli report import --workspace-id {workspaceId} --file report.pbix ● Update report content: pbicli report update-content --report-id {reportId} --file report.pbix ● Delete report: pbicli report delete --report-id {reportId}
6. Azure CLI Commands for Resource Management
● Login to Azure: az login
● Set subscription: az account set --subscription {subscriptionId} ● Create resource group: az group create --name {resourceGroupName} --location eastus ● Create Power BI Embedded capacity: az powerbi embedded create --name {capacityName} --resource-group {resourceGroupName} --sku-name A1 ● List Power BI Embedded capacities: az powerbi embedded list --resource-group {resourceGroupName}
By: Waleed Mousa
● Get Power BI Embedded capacity details: az powerbi embedded show --name {capacityName} --resource-group {resourceGroupName} ● Update Power BI Embedded capacity: az powerbi embedded update --name {capacityName} --resource-group {resourceGroupName} --sku-name A2 ● Delete Power BI Embedded capacity: az powerbi embedded delete --name {capacityName} --resource-group {resourceGroupName} ● Create service principal: az ad sp create-for-rbac --name {servicePrincipalName} ● Assign role to service principal: az role assignment create --assignee {servicePrincipalId} --role "Power BI Embedded" --scope /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}
7. Power BI Deployment Pipelines GUI Operations
● Create new pipeline: New-PowerBIPipeline -Name "Development to
● Get deployment rules: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/deployme ntRules" -Headers $headers -Method Get ● Create deployment rule: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/deployme ntRules" -Headers $headers -Method Post -Body $ruleJson ● Update deployment rule: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/deployme ntRules/{ruleId}" -Headers $headers -Method Patch -Body $updateRuleJson ● Delete deployment rule: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/deployme ntRules/{ruleId}" -Headers $headers -Method Delete ● Get deployment rule details: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/deployme ntRules/{ruleId}" -Headers $headers -Method Get ● Deploy to pipeline stage: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/stages/{ stageOrder}/deploy" -Headers $headers -Method Post -Body $deployJson ● Get deployment status: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/operatio ns/{operationId}" -Headers $headers -Method Get ● Cancel deployment: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/operatio ns/{operationId}/cancel" -Headers $headers -Method Post ● Get pipeline stage artifacts: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/stages/{ stageOrder}/artifacts" -Headers $headers -Method Get ● Compare pipeline stages: Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/pipelines/{pipelineId}/stages/c ompare" -Headers $headers -Method Get
9. PowerShell Scripts for Automation
● Get all reports in a workspace: $reports = Get-PowerBIReport
-WorkspaceId $workspaceId ● Export all reports in a workspace: Get-PowerBIReport -WorkspaceId $workspaceId | ForEach-Object { Export-PowerBIReport -Id $_.Id -OutFile "$($_.Name).pbix" }
By: Waleed Mousa
● Import multiple reports to a workspace: Get-ChildItem -Filter *.pbix | ForEach-Object { New-PowerBIReport -WorkspaceId $workspaceId -Path $_.FullName } ● Update all dataset parameters in a workspace: Get-PowerBIDataset -WorkspaceId $workspaceId | ForEach-Object { Set-PowerBIDatasetParameter -DatasetId $_.Id -ParameterName "ServerName" -ParameterValue "new-server" } ● Refresh all datasets in a workspace: Get-PowerBIDataset -WorkspaceId $workspaceId | ForEach-Object { Invoke-PowerBIDatasetRefresh -DatasetId $_.Id } ● Copy all reports to another workspace: Get-PowerBIReport -WorkspaceId $sourceWorkspaceId | ForEach-Object { Copy-PowerBIReport -Id $_.Id -TargetWorkspaceId $targetWorkspaceId } ● Delete all reports in a workspace: Get-PowerBIReport -WorkspaceId $workspaceId | ForEach-Object { Remove-PowerBIReport -Id $_.Id } ● Get all users for all workspaces: Get-PowerBIWorkspace | ForEach-Object { Get-PowerBIWorkspaceUser -WorkspaceId $_.Id } ● Add a user to all workspaces: Get-PowerBIWorkspace | ForEach-Object { Add-PowerBIWorkspaceUser -WorkspaceId $_.Id -UserEmailAddress "[email protected]" -AccessRight Member } ● Remove a user from all workspaces: Get-PowerBIWorkspace | ForEach-Object { Remove-PowerBIWorkspaceUser -WorkspaceId $_.Id -UserPrincipalName "[email protected]" }
10. Azure DevOps Pipeline Tasks
● Use Power BI Actions: - task: PowerBIActions@5
● Authenticate to Power BI: - task: PowerBIAuthenticate@5 ● Deploy Power BI report: - task: PowerBIDeployReport@5 ● Upload Power BI report: - task: PowerBIUploadReport@5 ● Update Power BI report content: - task: PowerBIUpdateReport@5 ● Delete Power BI report: - task: PowerBIDeleteReport@5 ● Refresh Power BI dataset: - task: PowerBIRefreshDataset@5 ● Update Power BI dataset parameters: - task: PowerBIUpdateDatasetParameters@5 ● Take over Power BI dataset: - task: PowerBITakeOverDataset@5 ● Add Power BI workspace user: - task: PowerBIAddWorkspaceUser@5
11. Power BI Deployment Pipelines Best Practices
By: Waleed Mousa
● Use separate workspaces for each stage: New-PowerBIWorkspace -Name "Development" -CapacityId $capacityId ● Implement naming conventions: $reportName = "Sales_Report_v1.0" ● Use deployment rules for consistent deployments: New-PowerBIDeploymentRule -PipelineId $pipelineId -RuleName "UpdateDataSource" -SourceStageOrder 0 -TargetStageOrder 1 ● Automate parameter updates between stages: Set-PowerBIDatasetParameter -DatasetId $datasetId -ParameterName "Environment" -ParameterValue "Test" ● Implement row-level security (RLS) across stages: Add-PowerBIDatasetRoleAssignment -DatasetId $datasetId -PrincipalType Group -PrincipalName "Sales Team" -RoleName "Sales" ● Use service principals for automated deployments: Connect-PowerBIServiceAccount -ServicePrincipal -CertificateThumbprint $certThumbprint -ApplicationId $appId ● Implement version control for reports: git add "Sales_Report_v1.0.pbix" ● Use incremental refresh for large datasets: Set-PowerBIDatasetRefreshSchedule -DatasetId $datasetId -Type Incremental -Frequency Daily -Time "01:00" ● Implement data gateway clustering: Add-PowerBIGatewayClusterDataSource -GatewayId $gatewayId -DatasourceType SQL -ConnectionDetails $connectionDetails ● Use dataset certification for trusted content: Set-PowerBIDatasetCertification -DatasetId $datasetId -CertificationStatus Certified
12. Error Handling and Logging
● Try-catch for error handling: try { Invoke-PowerBIRestMethod -Url
"pipelines/$pipelineId" -Method Get } catch { Write-Error $_.Exception.Message } ● Log pipeline operations: Write-Log "Deploying to Test stage: $pipelineId" ● Validate deployment before proceeding: if ($deploymentResult.Status -eq "Succeeded") { Proceed-ToNextStage } else { Rollback-Deployment } ● Implement custom error messages: throw "Failed to deploy report $reportId to stage $stageOrder" ● Use verbose logging for debugging: $VerbosePreference = "Continue"
(Ebook) Azure Data Factory Cookbook: Data engineers guide to build and manage ETL and ELT pipelines with data integration , 2nd Edition by Dmitry Foshin, Tonya Chernyshova, Dmitry Anoshin, Xenia Hertzenberg ISBN 9781803246598, 1803246596 2024 Scribd Download