Use Release Pipelines for automated deployment of Power BI files
During the development of BI-solutions most of the sources are well maintained: central source location, version control, tracking changes, and automated deployment. Yes, not everything. Most of the time data pipelines, database(s), and analysis service model(s) are controlled with a service like Azure DevOps. Power BI models and reports are often not controlled centrally. There are many reasons why and I did it too. But since I found out how easy it is to integrate your Power BI development process with Azure DevOps, I never create Power BI reports without Azure DevOps anymore.
Power BI Premium licenses give you some extra features like deployment pipelines. That’s great, but for many organizations, a premium license is like buying a Ferrari when you need a bicycle. So, in this blog series of 4 posts, I’ll show you how you can improve your Power BI development process big time with just some small steps using Azure DevOps. And you only need a Power BI pro license.
In this third blog post, we’ll create a Release pipeline that executes a PowerShell script, stored in Azure DevOps repos.
Prerequisites
- The Power BI file you want to deploy. This file is uploaded to Azure DevOps as part of your version control strategy. Check out this blog on how you can do that.
- A PowerShell script that deploys the Power BI file to your workspace. An example of this PowerShell script is discussed in this blog. This script is uploaded to Azure DevOps.
Create Release pipeline
In your Azure DevOps environment go to Pipelines –> Releases –> + New Pipeline.
Give your stage a proper name and click on the cross. Then we need to add an artifact. This artifact is our repository where out Powershell script is stored. So, click + Add next to Artifacts.
Select Azure Repos Git as source type. Then select your project, repository and branch where the Powershell script is stored. Then click Add.
We use variables to make our pipeline more dynamic. This is relevant if you use this release pipeline for different kinds of deployments (e.g. test and production). Click Variables on the top menu.
I’ll execute a PowerShell script that expects 3 input values. For this example, we use this PowerShell script. I’ll explain the script in this blog.
Click on the + sign next to Agent Job. Search for PowerShell and add the PowerShell task.
Fill in the following settings for the Powershell script:
- Script Path: Click on the ellipsis. This opens the Azure Repository you added as an artifact. Navigate to the Powershell script and select this file.
- Arguments: This Powershell script expects 3 input values. Assign the values to the appropriate variables you created before.
Click Save on the top right and then Ok. Now your pipeline is ready!
You can test your release pipeline by clicking Create release on the top right. You get a new pane on the right. Just click Create.
You can find the status of your release by clicking Release in the left menu. You need to wait for a few minutes (approx 6 min). It starts a VM in the background, which will cost most of the time. When the pipeline is finished, your Power BI file has been updated in your workspace.
Continuous Deployment
Clicking ‘Create Release’ every time you deploy does work, but you can make it easier for yourself. You can trigger a deployment pipeline every time a push occurs on a branch.
Let’s go back to the pipeline and click Edit on the top right.
Save the pipeline.
Conclusion
It’s quite easy to create a release pipeline and automate your Power BI deployment. The magic happens in the PowerShell script but Azure DevOps helps you to automate the deployment. We used the release pipelines here, which gives you a friendly UI. It’s an easy way to start. We just touched on a few options here. You can enhance the release pipeline with one of the many options in Azure DevOps. You can find information here.
Instead of release pipelines, you can also use Azure pipelines within Azure DevOps. You’ve more options and flexibility but often you have to ‘code’ YAML. In the next blog, I’ll show you how to create an Azure pipeline that deploys your Power BI file, without coding :).