REST API that could be consumed by a CI/CD pipeline. We’re using a PowerShell Commandlet giving some abstraction and still allowing us to make native calls to the REST API if the feature is missing.
After a few workshops we came to this development and deployment workflow :
We’ve added two new components to our workflow:
From a developer perspective, they can still deploy their report manually and we’ve added a new step to the workflow: they have to backup their work in the SCM in order to save and share it. To avoid the overriding of the work in progress, the pipeline has been configured to deploy on demand only (it’s a click on a button from the UI).
“Wanna go into production and make your end-users happy?”
It is done with the same components and handled from a SCM perspective. We took our inspiration from the GitLab Flow : we have 2 persistent branches, each persistent branch is to be deployed on a workspace.
Branch name | Workspace name |
main | development |
production | production |
We’ve gained the ability to audit and trace over the version of our released reports. Feature release is strongly coupled with feature deployment into the production workspace. Feature release/deployment is no longer done manually, but only from the pipeline. An update in the SCM on the production branch automatically triggers the pipeline.
(tips & stuff that went wrong)
Multiple reports can use a “shared dataset”: a .pbix file will contain only the data model (avoiding duplication) and the different reports (stored in different .pbix files) will consume the data stored in the shared dataset :
That being said, DO NOT put under version control shared dataset files: they contain the datasource's configuration (database URI, credentials, parameters)… but also cached data!
Each time the data is changed in our datasource, the shared dataset has to be refreshed. Operational data should not be put under version control.
DO NOT delete the development workspace shared dataset.
Reports using a shared dataset also contain the dataset identifier hard coded inside. If you delete the dataset, you can’t redeploy the report without editing the report. The report is strongly coupled with the dataset, the configuration is not externalized nor separated from the code, in contradiction with the third factor of the TwelveFactor App : Store config in the environment.
REST API calls are only available to a Power BI workspace with premium capacity based 💰.
Power BI Reports APIs are documented with a “Try It” functionality (like a Swagger UI) giving a developer portal experience. While the PowerShell Command encapsulates some of the complexity, we have observed that parallel calls returned in error and debugging is painful due to lack of actionable error logs.
Authentication can be done through two OAuth2 flows:
In both cases, documentation surrounding it is not self-explanatory. The documentation doesn’t cover authentication implementation. Our pipeline needs a client id and client secret to authenticate and consume Power BI REST endpoints. The code below is the result of trial and error without guidance from the official documentation.
💡Configure your deployment to have report deployment idempotency
In the following scenario, we want to deploy the same report in two different workspaces using dedicated credentials from the pipeline.
Remember: the dataset ID is hard coded in the report.
So the green report is linked to the blue dataset but the credentials used to deploy in the green workspace have no permission on the blue workspace (nor should it have any).
Option 1 : make an API call to “rebind” the green report to the green dataset post deployment, leaving a hole in our workspace segregation. The shared dataset must ensure backwards compatibility.
Option 2 : start The Clone Wars 🤖🤖🤖
Apply a clone operation between workspaces, creating a copy of the report AND the dataset in the target workspace.
Adding a cleanup process to avoid dataset duplication and old versions of reports.
The update process will be different from the create process complexifying the pipeline.
In both cases,
We went with the first option to keep it simple : a single operation is required post deployment (vs clean old report and rebinding other reports to the new shared dataset).
Aside from the method we chose, there are some third party extensions available in the Azure Marketplace that use the PowerShell modules to interact with Power BI Service. The 2 most popular extensions, Macaw and Actions, allow to control Power BI deployment. Both extensions are covering the same perimeter easing the work with Azure pipelines. Actions covers a broader range of possibilities to interact with Power BI.
The table below highlights the different tasks that can be performed by these extensions.
Tasks | Macaw | Actions |
Create or Update Power BI workspace | yes | yes |
Delete Power BI Workspace | yes | yes |
Write all workspace info to JSON logfile | yes | no |
Upload or Update Power BI report | yes | yes |
Delete Power BI report | yes | no |
Delete Power BI dataset | yes | no |
Update the data sources of the specified dataset | yes | no |
Update the parameters values for the specified dataset | yes | no |
Update gateway | no | yes |
Update a dataset | no | yes |
Certified by Microsoft | Yes | No |
Last update | Nov. 19 | Dec. 20 |
Please note that these packaged solutions have limitations:
Leveraging your own PowerShell script will grant you more flexibility during the build & run activities.
After exploring the solutions using XMLA endpoints to manage and deploy Power BI datasets, we are investigating a functionality released in May 2020: Deployment Pipeline.
In short, this new functionality is a low-code approach enabling to move .pbix files between environments (here, workspaces). How does it work?
Limitations:
During the implementation of the deployment pipeline, we have noticed two major limitations:
Looking back in the mirror, did we accomplish our goals?
On a technical aspect, we have a bittersweet feeling. Among the two objectives we had (version control and continuous deployment), only the version control has been fully adopted by the Power BI team. Regarding the fully automated continuous deployment using the REST API, we remained at a POC version. With the release of the deployment pipeline by Microsoft, we have decided to leverage this solution in production.
On a cultural aspect, definitely. Cultural change cannot be imposed, cannot be forced nor directly addressed. Cultural transformations are made through practice and the observation of convincing results. We have chosen to focus this blog post on the technical result but these are the fruits of collaboration during workshops and pair programming, acculturation of DevOps/Craft practices. Today, the datavisualization team members act as evangelists in the BI projects they are working on.
What are the lessons learned?
In our opinion, the maturity of Power BI and, more generally, the maturity of packaged tools is the central element of what we have learned.
The maturity is changing rapidly. Implementing a state of art continuous deployment at the time of this project (end of 2020) was not possible. However, Microsoft has upgraded the Power BI REST API in June 2021 allowing the integration of the deployment pipeline with Azure DevOps.
Many data visualization tools were born before the emergence of DevOps, which explains the need to upgrade development practices (from both the software editors and the developers).
It’s only a matter of time before the tools are adjusted and the practices are widespread within the teams. In the meantime, ask yourself : how much do I want to invest in tool customization to implement DevOps practices ?