
Modernizing Power BI Development: A Project with PBIP, TMDL, CI/CD, and More
- May 1st, 2025
- 152 Views
For years, developing Power BI solutions often felt like a solitary endeavor, with limited options for version control and streamlined deployment. However, the introduction of the Power BI Project (.pbip) file format marks a significant shift, opening the door to modern development workflows. When combined with tools like Tabular Model Definition Language (TMDL), Tabular Model Scripting Language (TMSL), Continuous Integration/Continuous Deployment (CI/CD) pipelines in Azure DevOps, the pbi-sm PowerShell module, and Git for version control, we can create a powerful and collaborative development experience.
This article will guide you through setting up and managing a Power BI Desktop project using these technologies, culminating in an automated deployment process using PowerShell.
Laying the Foundation: The Power BI Project (PBIP)
The .pbip format is a container that holds all the elements of your Power BI Desktop project in a structured way. Unlike the monolithic .pbix file, a .pbip project breaks down into individual files, making it ideal for version control and collaborative development.
Key benefits of using .pbip:
â—¾Version Control Friendly: The decomposed structure allows Git to track changes at a granular level, enabling effective collaboration and history management.
â—¾Modularity: Separating metadata (TMDL), reports (JSON), and other assets enhances organization and maintainability.
â—¾Extensibility: The open format paves the way for future tooling and automation.
Getting Started with .pbip:
This will create a folder containing your project files, including:
â—¾<Project Name>.SematicModel: While .pbip aims for TMDL, initially, the model might be stored in the traditional.bim format. Power BI Desktop will handle the serialization and deserialization.
â—¾<Project Name>.Report: Contains the visual layout and configuration in JSON format.
â—¾<Project Name>.pbip
â—¾.gitignore – Allows you to define exclusions.
Defining Your Data Model with TMDL
Tabular Model Definition Language (TMDL) is a declarative language for defining tabular models. It aims to replace the binary.bim format with a human-readable and version-control-friendly text-based representation.
Benefits of TMDL:
â—¾Human-Readable: Easier to understand and review model definitions.
â—¾Version Control Integration: Text-based format integrates seamlessly with Git for tracking changes to your data model.
â—¾Automation-Friendly: Simplifies programmatic manipulation and deployment of tabular models.
Working with TMDL:
Currently, direct editing of TMDL files within Power BI Desktop isn't fully implemented. However, Power BI Desktop will serialize the model into a .bim file within the .pbip structure. Future updates are expected to bring more direct TMDL support. Tools like Tabular Editor 3 offer excellent capabilities for viewing, editing, and scripting TMDL.
Scripting Model Changes with TMSL
Tabular Model Scripting Language (TMSL) is a JSON-based scripting language for managing and querying tabular models in Analysis Services, including the Power BI semantic model. While TMDL defines the structure of the model, TMSL is used to perform actions on it, such as refreshing data, processing objects, or deploying metadata.
Use Cases for TMSL in a .pbip Project:
â—¾Automating Refreshes: Incorporate TMSL scripts into your CI/CD pipeline to automatically refresh the semantic model after deployment.
â—¾Partition Management: Script the creation, modification, or deletion of partitions.
â—¾Role and Permission Management: Automate the assignment of roles and permissions.
You can execute TMSL scripts using tools like SQL Server Management Studio (SSMS) connected to your Power BI Premium capacity or through PowerShell using the Invoke-ASCmd cmdlet from the SQL Server module.
Version Control with Git
Git is the industry-standard distributed version control system. Integrating your .pbip project with Git is crucial for:
â—¾Collaboration: Multiple developers can work on the same project simultaneously without conflicts.
â—¾Tracking Changes: Every modification is recorded, allowing you to revert to previous versions if needed.
â—¾Branching and Merging: Enables the creation of isolated environments for developing new features or fixing bugs.
Setting up Git for your .pbip Project:
Initialize a Repository: Navigate to your .pbip project folder in your terminal or Git client and run git init.i. Open your project
â—¾Set up a terminal
Git Terminal can be downloaded from Install and set up Git - Azure DevOps | Microsoft Learn
Install Visual Studio Code Development Environment – if you already have it proceed to next steps https://code.visualstudio.com/
â—¾Once done with installation, access VS Code and set up a repository
i. Open your project
Continuous Integration and Continuous Deployment (CI/CD) with Azure DevOps
Azure DevOps provides a suite of services for managing the software development lifecycle, including Azure Pipelines for CI/CD. Implementing a CI/CD pipeline for your Power BI project automates the build, test, and deployment processes.
CI/CD Workflow for a .pbip Project:
â—¾Validation: Potentially validate the project structure or run basic checks.
â—¾Artifact Creation: Package the necessary files from your .pbip project for deployment. This might involve zipping the contents of the .pbip folder.
â—¾Environment Configuration: Define different environments (e.g., Development, Test, Production).
â—¾Deployment Tasks: Utilize PowerShell scripts and the pbi-sm module (explained below) to deploy the Power BI artifacts to the appropriate Power BI service workspace. This could involve publishing the semantic model and reports.
â—¾Testing: Run automated tests against the deployed solution.
Empowering Deployment with pbi-sm PowerShell Module
The pbi-sm PowerShell module is specifically designed for managing Power BI semantic models (formerly known as datasets) and other Power BI Service artifacts programmatically. It provides cmdlets for various tasks, making it invaluable for automation.23
Key pbi-sm Cmdlets for Deployment:
â—¾Connect-PowerBIServiceAccount: Connects to your Power BI Service tenant.
â—¾Import-PowerBIReport: Imports a .pbix file (or the relevant artifacts from your .pbip project) as a report and semantic model.
â—¾Publish-PowerBIDataflow: Publishes a dataflow.
â—¾Update-PowerBIReport: Updates an existing report.
â—¾Invoke-PowerBIRefresh: Triggers a refresh of a semantic model.
â—¾Get-PowerBIWorkspace, Get-PowerBIDataset, etc.: Cmdlets for retrieving information about your Power BI Service environment.
Automating Deployment with PowerShell and Azure DevOps
Combining the pbi-sm module with Azure Pipelines allows for fully automated deployment of your .pbip project.
Example PowerShell Deployment Script (Simplified):
PowerShell
param(
[Parameter(Mandatory=$true)]
[string]$PBIWorkspaceName,
[Parameter(Mandatory=$true)]
[string]$PBIPProjectPath
)
# Connect to Power BI Service
Connect-PowerBIServiceAccount
# Construct the full path to the .pbix file (assuming a simple conversion for this example)
$PBIXFilePath = Join-Path $PBIPProjectPath "model.bim" # Or potentially create a .pbix from the .pbip
# Get the target workspace
$Workspace = Get-PowerBIWorkspace -Name $PBIWorkspaceName
if (-not $Workspace) {
Write-Error "Workspace '$PBIWorkspaceName' not found."
exit 1
}
# Publish the PBIX (or the relevant artifacts)
Import-PowerBIReport -Path $PBIXFilePath -WorkspaceId $Workspace.Id -Name "YourReportName" -Overwrite
Write-Host "Power BI report and semantic model deployed to '$PBIWorkspaceName'."
# Optional: Trigger a refresh
# $Dataset = Get-PowerBIDataset -WorkspaceId $Workspace.Id -Name "YourReportName"
# if ($Dataset) {
# Invoke-PowerBIRefresh -DatasetId $Dataset.Id
# Write-Host "Semantic model refresh initiated."
# }
Integrating this script into an Azure DevOps Pipeline:
â—¾Set the Script Type to "Inline".
â—¾Paste your PowerShell deployment script into the Inline Script field.
â—¾Define variables for $PBIWorkspaceName and $PBIPProjectPath (you can configure these in the pipeline variables).
â—¾Ensure the Azure DevOps agent has the necessary permissions to connect to the Power BI Service (usually through a Service Principal).
Conclusion
Embracing the .pbip format and integrating it with TMDL (as it matures), TMSL, Git, Azure DevOps, and the pbi-sm PowerShell module represents a significant step forward in modernizing Power BI development. This approach fosters collaboration, enhances version control, and enables robust automation of your deployment processes. By adopting these practices, you can build more reliable, maintainable, and scalable Power BI solutions, ultimately empowering your organization with timely and accurate insights. As the Power BI ecosystem continues to evolve, staying ahead of these modern development paradigms will be key to maximizing your team's efficiency and the quality of your BI deliverables.