Integrating Power BI with Azure DevOps (Git), part 2: Local Machine Integration

Integrating Power BI with Azure DevOps (Git), part 2: Local Machine Integration

This is the second part of the series of blog posts showing how to integrate Power BI with Azure DevOps, a cloud platform for software development. The previous post gave a brief history of source control systems, which help developers manage code changes. It also explained what Git is, a fast and flexible distributed source control system, and why it is useful. It introduced the initial configurations required in Azure DevOps and explained how to integrate Power BI (Fabric) Service with Azure DevOps.

This blog post explains how to synchronise an Azure DevOps repository with your local machine to integrate your Power BI Projects with Azure DevOps. Before we start, we need to know what a Power BI Project is and how we can create it.

What is Power BI Project (Developer Mode)

Power BI Project (*.PBIP) is a new file format for Power BI Desktop that was announced in May 2023 and made available for public preview in June 2023. It allows us to save our work as a project, which consists of a folder structure containing individual text files that define the report and dataset artefacts. This enables us to use source control systems, such as Git, to track changes, compare revisions, resolve conflicts, and review changes. It also enables us to use text editors, such as Visual Studio Code, to edit the artefact definitions more productively and programmatically. Additionally, it supports CI/CD (continuous integration and continuous delivery), where we submit changes to a series of quality gates before applying them to the production system.

PBIP files differ from the regular Power BI Desktop files (PBIX), which store the report and dataset artefacts as a single binary file. This made integrating with source control systems, text editors, and CI/CD systems difficult. PBIP aims to overcome these limitations and provide a more developer-friendly experience for Power BI Desktop users.

Since this feature is still in public preview when writing this blog post, we have to enable it from the Power BI Desktop Options and Settings.

Enable Power BI Project (Developer Mode) (Currently in Preview)

As mentioned, we first need to enable the Power BI Project (Developer Mode) feature, introduced for public preview in the June 2023 release of Power BI Desktop. Power BI Project files allow us to save our Power BI files as *.PBIP files deconstruct the legacy Power BI report files (*.PBIX) into well-organised folders and files.
With this feature, we can:

  • Edit individual components of our Power BI file, such as data sources, queries, data model, visuals, etc.
  • Use any text editor or IDE to edit our Power BI file
  • Compare and merge changes
  • Collaborate with other developers on the same Power BI file

To enable Power BI Project (Developer Mode), follow these steps in Power BI Desktop:

  1. Go to File
  2. Click Options and settings
  3. Click Options
Power BI Desktop options
  1. In the Options dialog box, go to Preview features
  2. Check the box next to Power BI Project files
  3. Click OK
Enabling Power BI Project (.PBIP) save option in Power BI Desktop

After applying the changes, we need to restart the Power BI Desktop.

Clone the Git repository on your local machine using VS Code

The first post of this series explained how to create a new Organisation, Project, and Repo in Azure DevOps. So, we do not repeat those steps here. Instead, this section explains how to clone our Git repository created on Azure DevOps on the local machine. Cloning is the process of copying a remote repository to a local machine so that we can work on the project offline.

To clone a Git repo on a local machine, we require either to install Visual Studio or Visual Studio Code (VS Code) on the local machine. We can also use Git Command Line for cloning. The latter is out of the scope of this blog, so we focus on using the VS Code methods.

Note

Regardless of the desired cloning method, we have to install Git on the local machine.

Follow these steps to close Azure DevOps Repos with VS Code:

  1. In your web browser, navigate to your Azure DevOps Organization using this pattern: https://dev.azure.com/{your_organization_name}
  2. Click the desired Project
Navigating to Azure DevOps Organization and Project
  1. Click Repos
  2. Click the Clone button
  3. From the Clone Repository pane, click the Clone in VS Code button
  4. Click the Open button
Cloning Azure DevOps Repos in VS Code
  1. Now you get a message on VS Code to Allow an extension to open this URL; click the Open button
Allow an extension to open Azure DevOps Repo URL in VS Code
  1. Select a Folder to clone files
  2. Click the Select as Repository Destination button
Select a Folder as Repository Destination
  1. Pass your credentials on the Git Credential Manager and click the Sign in button
Pass Credentials on the Git Credential Manager

We are done now. You can click either the Open button to navigate to the selected cloned repo within the VS Code or click the Open in New Window button to open a new instance of VS Code and navigate to the cloned repo.

Open the Cloned Azure DevOps Repo in VS Code

So far, we have cloned an Azure DevOps repo with VS Code. The next step is to create a Power BI Project.

Create a Power BI Project

The next step is to create a Power BI Project using Power BI Desktop. You can either create a new project from scratch or convert an existing PBIX file into a Power BI Project file (PBIP). In this blog post, I create a new file from scratch.

To create a Power BI Project file, follow these steps:

  1. Open a new instance of Power BI Desktop, then click the File menu
  2. Click the Save as option
  3. Click the Browse this device

Note

You may want to save the project in your OneDrive. In that case select the OneDrive option on the Save as menu.

  1. In the Save As dialog box, choose the location of the cloned Azure DevOps repo
  2. Type in a name for your file
  3. In the Save as type drop-down list, select the Power BI Project files (*.pbip) option
  4. Click Save
Creating a Power BI Project from scratch in Power BI Desktop

When we navigate to the location where we saved the project, we will see that the folder contains the following:

  • The PBIP From Scratch.pbip file
  • A PBIP From Scratch.Dataset folder
  • A PBIP From Scratch.Report folder

You can explore and edit these folders and files using Power BI Desktop or any other tool of your choice such as Tabular Editor or even a notepad editor such as Notepad++.

Now that we created the Power BI project, let’s carry on and create a simple data model and report.
Since this is just a simple test, we can connect to any data source of choice, I use Microsoft’s SQL Server sample database: AdventureWorks2022DW.
In my sample, I get data from the following tables:

  • DimDate
  • DimProduct
  • FactInternetSales

I also created a new measure as below:

Sales = SUM(FactInternetSales[SalesAmount])

Then I created a simple report with a slicer and a line chart as follows, and I saved the changes locally on my machine:

A Sample Report in Power BI Desktop

Now on VS Code:

  1. The Source Control pane detected a couple of changes
  2. To commit the changes we enter a comment that explains what we have done
  3. Click the Commit button to commit the changes to Azure DevOps Repo
Committing the changes on our local machine in VS Code

Depending on your VS Code settings, you may get the following message on VS Code saying “There are no staged changes to commit. Would you like to stage all your changes and commit them directly?” as shown in the following image. This question asks you if you would like to Stage all changes first, and then Commit them locally. Learn more about Staging changes and Committing here.

I select Always as I don’t want VS Code to ask the same question again in the future.

Stage all your changes and commit them directly

So far, we committed changes to our local machine, we now want to publish the changes to Azure DevOps.

  1. Type in a comment
  2. Click the Publish Branch button
Publishing Branch in VS Code after Commit

Check Azure DevOps Repo for Changes

Now, we successfully Pushed all changes to the Azure DevOps repo. The next step is to check the DevOps repo. Checking if the changes have gone through on Azure DevOps is easy. We just need to navigate to the desired Project on Azure DevOps.

Changes successfully pushed to Azure DevOps repo

Check Fabric Workspace for Changes

Log into Fabric and navigate to the desired Workspace. If you correctly configured Git Integration from the Workspace Settings, you should see that the Workspace contents synchronised with the Azure DevOps repo.

Check Fabric Workspaces for Synching with Azure DevOps

As you see, in my case, the synchronisation was successful. Now, let’s open the report and see if it is actually working.

Running the synchronised report Azure DevOps on Fabric

As you can see, the report is empty. This is because the Git integration in Fabric only synchronises the dataset and report definitions, not the data. Therefore, we have to either refresh the dataset or Publish the report to Fabric from Power BI Desktop.

Note

Since we work on a Power BI Project, if you use older versions of Power BI Desktop than the Aug 2023 release, the Publish button is disabled.

This is it for this blog post.
In the next blog, we look at some real-world working scenarios and discuss current limitations and considerations.
So stay tuned for that.

As always, I would love to know your opinion and thoughts. So please share with us what you think in the comments section below.