Skip to main content

Deep Dive: Automation with Fabric CLI and REST

Overview

In software-defined data infrastructure, automation is a cornerstone of scaling, consistency, and efficiency. In the context of Microsoft Fabric Landing Zones, the platform automation approach should incorporate the Fabric CLI, Fabric REST APIs, and proven DevOps pipelines to realize full lifecycle automation — from provisioning to configuration and ongoing operations.

Key Automation Principles

  • Everything as Code (EaC): Include IaC, PaC (Policy as Code), DaC (Deployment as Code), and even Docs as Code. Store and version everything in Git.
  • 4-Eyes Principle: Require peer reviews and branch policies to maintain quality and transparency.
  • CI/CD Pipelines: Use GitHub Actions or Azure DevOps to trigger validation and deployments on pull requests or merges.

Fabric-Specific Automation

Fabric CLI

The Fabric CLI is a command-line tool to interact with Microsoft Fabric resources such as:

  • Workspaces
  • Pipelines
  • Dataflows
  • Notebooks
  • Datasets
  • Reports

Typical Use Cases:

  • Automate workspace setup: fabric workspace create --name "Finance"
  • Deploy semantic models: fabric dataset deploy --workspace "Finance" --file model.json
  • CI/CD for reports: Use fabric report export/import to version and deploy reports.

Documentation: Fabric CLI documentation on learn.microsoft.com

Fabric REST API

For advanced automation and integration with custom platforms, the Fabric REST API provides access to:

  • Workspace provisioning
  • Artifact management (pipelines, reports, etc.)
  • Role assignments and access control
  • Job status and scheduling

Common REST automation tasks:

  • Programmatic report deployment
  • Auditing workspace and artifact metadata
  • Integrating external systems like ticketing or monitoring

Documentation: Fabric REST API Reference

Example REST API Script (Python)

Here’s an example using Python requests to deploy a report:

import requests

url = "https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/reports"
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
}
payload = {
"name": "SalesReport",
"source": {
"file": "https://yourblob.blob.core.windows.net/fabric/report.pbix"
}
}

response = requests.post(url, headers=headers, json=payload)
print(response.status_code, response.json())

Policy as Code (PaC)

Using Azure Policy with IaC tools like Bicep or Terraform, you can enforce controls across all Fabric-related Azure resources, including:

  • Restricting SKUs for Power BI capacities
  • Mandating private endpoints for Fabric Lakehouses
  • Enforcing tagging and cost-center tracking

Tooling Recommendations:

  • Use Enterprise Policy as Code (EPAC) for scalable, testable policy management.
  • Combine PaC with Fabric CLI in pipelines to validate and enforce before deployment.

Automation Architecture in a Fabric Landing Zone

  • IaC: Deploy shared services and foundational elements (e.g., capacity SKUs, Log Analytics, Purview).
  • PaC: Apply baseline governance to all workspaces and resources.
  • Fabric CLI + REST: Provision and deploy Fabric workloads and content.
  • DevOps Pipelines: Trigger validations, tests, and deployments.

Best Practices

  • Start with small units (e.g., workspace provisioning) and gradually expand automation coverage.
  • Define a governance gate using policies to block non-compliant resources.
  • Automate rollback paths and monitor drift using policy compliance reports and Git diffs.

Sample CI/CD Workflow with Fabric CLI

Below is a simplified GitHub Actions YAML snippet to deploy a semantic model and report using the Fabric CLI:

name: Deploy Fabric Artifacts

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Fabric CLI
run: |
npm install -g @microsoft/fabric-cli
fabric login --service-principal -t ${{ secrets.FABRIC_TENANT_ID }} -i ${{ secrets.FABRIC_CLIENT_ID }} -s ${{ secrets.FABRIC_CLIENT_SECRET }}

- name: Deploy dataset
run: fabric dataset deploy --workspace "Finance" --file artifacts/model.json

- name: Deploy report
run: fabric report import --workspace "Finance" --file artifacts/report.pbix

Next Steps

Contributors