Skip to main content

Infrastructure as Code (IaC) in Microsoft Fabric

Infrastructure as Code (IaC) is the practice of provisioning and managing your environment using declarative or scripted definitions—rather than manual steps via a UI. In Microsoft Fabric, adopting IaC is essential for repeatability, governance, and productivity, particularly when managing large-scale, cross-team environments.

This chapter outlines best practices, supported technologies, and practical examples for implementing IaC with Microsoft Fabric, including Azure CLI, REST APIs, XMLA endpoint, and GitOps-driven workflows.


Why IaC in Microsoft Fabric?

Adopting IaC provides multiple advantages for managing Fabric environments:

  • Repeatability: Define environments once and deploy consistently across dev, test, and production.
  • Auditability: All configurations live in version-controlled repositories.
  • Speed & Efficiency: Automate resource provisioning and updates.
  • Collaboration: Enable peer reviews, CI/CD, and branching strategies.
  • Governance: Enforce standards through templates and automation.

IaC Tools & Interfaces for Microsoft Fabric

Microsoft Fabric integrates with several automation tools and APIs that support Infrastructure as Code workflows:

A core productivity tool for developing and managing IaC artifacts is Visual Studio Code (VS Code). With extensions like Azure CLI Tools, REST Client, GitLens, and Bicep or Terraform extensions, VS Code becomes a powerful IDE for authoring, testing, and deploying your infrastructure definitions. Teams can use features like code completion, syntax highlighting, integrated terminals, and Git integration to streamline development workflows.

1. Azure CLI

The Azure CLI allows scripting operations on Fabric capacities, workspaces, and permissions. It's ideal for embedding into deployment pipelines or for scripting changes at scale.

Example: Create a Fabric workspace

az login
az account set --subscription "<your-subscription-id>"
az fabric workspace create \
--name "finance-reporting" \
--location "westeurope" \
--resource-group "rg-data-platform"

2. Microsoft Fabric REST APIs

The Fabric REST APIs give low-level control over datasets, workspaces, permissions, capacities, and more.

Example: Deploy a semantic model via REST

PUT /groups/{workspaceId}/datasets/{datasetId}
Authorization: Bearer <access-token>
Content-Type: application/json

{
"name": "SalesModel",
"defaultMode": "Push",
"description": "Automated deployment of sales dataset"
}

Use tools like Postman, curl, or SDKs (e.g. Python requests, C# HttpClient) to work with the Fabric REST API.

3. XMLA Endpoint

For advanced scenarios involving Tabular models (Analysis Services), the XMLA endpoint enables automation of deployments using scripting languages like TMSL (Tabular Model Scripting Language).

Example: Deploying a Tabular model with TMSL

{
"createOrReplace": {
"object": {
"database": "SalesAnalysis"
},
"database": {
"name": "SalesAnalysis",
"id": "SalesAnalysis",
"compatibilityLevel": 1600,
"model": {
"tables": [
{
"name": "Sales",
"columns": [...]
}
]
}
}
}
}

Tools: SQL Server Management Studio (SSMS), Tabular Editor, PowerShell, or REST API with ExecuteCommands.


GitOps and Deployment Pipelines

Use Git repositories as your single source of truth:

  • Store Fabric definitions in Bicep, JSON, or script files.
  • Trigger deployments via GitHub Actions, Azure DevOps Pipelines, or Terraform Cloud.

Example GitHub Workflow

name: Deploy Fabric Workspace

on:
push:
branches: [ "main" ]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Create workspace
run: |
az fabric workspace create \
--name "prod-reporting" \
--location "westeurope" \
--resource-group "rg-prod"

Everything-as-Code (EaC)

In addition to IaC, adopt other "*-as-Code" practices:

  • Policy as Code: Use Azure Policy to govern resource creation and compliance.
  • Documentation as Code: Use Markdown and version control for operational documentation.
  • Deployment as Code: Use ARM/Bicep/Terraform or custom pipelines.

Best Practices

  • Use branch protection policies and pull request reviews to enforce quality.
  • Tag all deployments with metadata for auditing and traceability.
  • Treat emergency changes as temporary and track them in the backlog for proper IaC refactoring.
  • Use parameterization and templates to avoid duplication.
  • Keep test and production environments in sync via IaC.
  • Enable Privileged Identity Management (PIM) and avoid permanent admin rights.

Summary

Microsoft Fabric offers a rich ecosystem for adopting IaC and automating your data platform. Whether through CLI, REST, or XMLA—automating your platform gives you agility, governance, and scalability. Begin small, iterate, and let your automation journey evolve as your platform matures.

For more details, see: Automate Microsoft Fabric

Contributors