{
  "nbformat": 4,
  "nbformat_minor": 5,
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.13.0"
    },
    "blog_metadata": {
      "topic": "Microsoft Fabric at Scale: The Governance Patterns That Matter Before You Expand",
      "slug": "microsoft-fabric-at-scale-the-governance-patterns-that-matte",
      "generated_by": "LinkedIn Post Generator + Azure OpenAI",
      "generated_at": "2026-10-22T18:39:59.425Z"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Microsoft Fabric at Scale: The Governance Patterns That Matter Before You Expand\n",
        "\n",
        "Microsoft Fabric scale is an operating-model decision, not just a provisioning exercise. This notebook turns the blog post into hands-on validation patterns you can run locally to test governance guardrails before broad rollout. The focus is on control planes, workspace standards, access governance, environment isolation, and cost visibility."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "%pip install pandas matplotlib networkx"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "import re\n",
        "import json\n",
        "from typing import List, Dict, Set\n",
        "\n",
        "import pandas as pd\n",
        "import matplotlib.pyplot as plt\n",
        "import networkx as nx"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Governance model overview\n",
        "\n",
        "This cell visualizes the core operating model from the post: domains move quickly inside a control plane they did not invent. The center owns policy, guardrails, and visibility; domains own delivery within those boundaries."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "import matplotlib.pyplot as plt\n",
        "import networkx as nx\n",
        "\n",
        "G = nx.DiGraph()\n",
        "\n",
        "edges = [\n",
        "    (\"Business Domains\", \"Fabric Capacity\"),\n",
        "    (\"Fabric Capacity\", \"Workspaces\"),\n",
        "    (\"Workspaces\", \"Lakehouses / Warehouses / Notebooks\"),\n",
        "    (\"Workspaces\", \"Semantic Models / Reports\"),\n",
        "    (\"Central Governance Team\", \"Policies\"),\n",
        "    (\"Policies\", \"Workspaces\"),\n",
        "    (\"Policies\", \"Lakehouses / Warehouses / Notebooks\"),\n",
        "    (\"Policies\", \"Semantic Models / Reports\"),\n",
        "    (\"Purview / Catalog\", \"Lakehouses / Warehouses / Notebooks\"),\n",
        "    (\"Purview / Catalog\", \"Semantic Models / Reports\"),\n",
        "    (\"Monitoring & Cost Controls\", \"Fabric Capacity\"),\n",
        "    (\"Monitoring & Cost Controls\", \"Workspaces\"),\n",
        "]\n",
        "\n",
        "G.add_edges_from(edges)\n",
        "\n",
        "pos = {\n",
        "    \"Business Domains\": (-2, 1),\n",
        "    \"Fabric Capacity\": (-1, 1),\n",
        "    \"Workspaces\": (0, 1),\n",
        "    \"Lakehouses / Warehouses / Notebooks\": (1, 1.4),\n",
        "    \"Semantic Models / Reports\": (1, 0.6),\n",
        "    \"Central Governance Team\": (-2, -0.2),\n",
        "    \"Policies\": (-1, -0.2),\n",
        "    \"Purview / Catalog\": (0, -1.0),\n",
        "    \"Monitoring & Cost Controls\": (-1.5, -1.6),\n",
        "}\n",
        "\n",
        "plt.figure(figsize=(12, 6))\n",
        "nx.draw(\n",
        "    G,\n",
        "    pos,\n",
        "    with_labels=True,\n",
        "    node_size=3200,\n",
        "    node_color=\"#D9EAF7\",\n",
        "    font_size=9,\n",
        "    arrows=True,\n",
        "    arrowstyle=\"-|>\",\n",
        "    arrowsize=16,\n",
        ")\n",
        "plt.title(\"Fabric Governance Control Plane\")\n",
        "plt.axis(\"off\")\n",
        "plt.show()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Workspace naming standard validator\n",
        "\n",
        "The original post used PowerShell to validate workspace names. Here, the same idea is implemented in Python so you can test whether names consistently encode domain, environment, and workload type."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "import re\n",
        "\n",
        "workspace_names = [\"FIN-PRD-ANL\", \"HR-DEV-DS\", \"bad-name\"]\n",
        "pattern = r'^[A-Z]{2,5}-(DEV|TST|PRD)-(ANL|BI|DS)$'\n",
        "\n",
        "for name in workspace_names:\n",
        "    if re.match(pattern, name):\n",
        "        print(f\"VALID: {name}\")\n",
        "    else:\n",
        "        print(f\"INVALID: {name}\")"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Workspace metadata gate before promotion\n",
        "\n",
        "This example enforces required governance metadata before a workspace can be promoted. The point is to make ownership and classification machine-readable instead of relying on tribal knowledge."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "required_tags = {\"owner\", \"data_domain\", \"environment\", \"criticality\"}\n",
        "\n",
        "workspaces = [\n",
        "    {\"name\": \"FIN-PRD-ANL\", \"tags\": {\"owner\": \"finops\", \"data_domain\": \"finance\", \"environment\": \"prod\", \"criticality\": \"high\"}},\n",
        "    {\"name\": \"HR-DEV-DS\", \"tags\": {\"owner\": \"hr-team\", \"environment\": \"dev\"}}\n",
        "]\n",
        "\n",
        "for ws in workspaces:\n",
        "    missing = sorted(required_tags - set(ws[\"tags\"].keys()))\n",
        "    if missing:\n",
        "        print(f\"BLOCKED {ws['name']}: missing tags {missing}\")\n",
        "    else:\n",
        "        print(f\"APPROVED {ws['name']}: governance metadata complete\")"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Deployment pipeline with governance checks\n",
        "\n",
        "This cell recreates the sequence diagram as executable logic. A domain team submits a change, governance checks validate naming, tags, and environment, and the pipeline either deploys or rejects the request."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "import re\n",
        "\n",
        "required_tags = {\"owner\", \"data_domain\", \"environment\", \"criticality\"}\n",
        "name_pattern = r'^[A-Z]{2,5}-(DEV|TST|PRD)-(ANL|BI|DS)$'\n",
        "allowed_env_values = {\"dev\", \"test\", \"tst\", \"prod\", \"prd\"}\n",
        "\n",
        "submission = {\n",
        "    \"workspace\": \"FIN-PRD-ANL\",\n",
        "    \"tags\": {\n",
        "        \"owner\": \"finops\",\n",
        "        \"data_domain\": \"finance\",\n",
        "        \"environment\": \"prod\",\n",
        "        \"criticality\": \"high\"\n",
        "    }\n",
        "}\n",
        "\n",
        "def validate_submission(item: dict):\n",
        "    violations = []\n",
        "    if not re.match(name_pattern, item[\"workspace\"]):\n",
        "        violations.append(\"invalid workspace naming standard\")\n",
        "    missing = sorted(required_tags - set(item.get(\"tags\", {}).keys()))\n",
        "    if missing:\n",
        "        violations.append(f\"missing tags: {missing}\")\n",
        "    env_value = item.get(\"tags\", {}).get(\"environment\", \"\").lower()\n",
        "    if env_value not in allowed_env_values:\n",
        "        violations.append(\"invalid environment tag value\")\n",
        "    return violations\n",
        "\n",
        "violations = validate_submission(submission)\n",
        "\n",
        "print(\"Domain Team -> Pipeline: Submit workspace/artifact change\")\n",
        "print(\"Pipeline -> Governance Checks: Validate naming, tags, environment\")\n",
        "if violations:\n",
        "    print(f\"Governance Checks -->> Pipeline: Fail ({'; '.join(violations)})\")\n",
        "    print(\"Pipeline -->> Domain Team: Reject with policy violations\")\n",
        "else:\n",
        "    print(\"Governance Checks -->> Pipeline: Pass\")\n",
        "    print(\"Pipeline -> Fabric Workspace: Deploy artifacts\")\n",
        "    print(\"Fabric Workspace -->> Domain Team: Deployment complete\")"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Role-size thresholding for least privilege\n",
        "\n",
        "This example flags oversized role assignments. It helps identify access drift, especially when broad viewer or contributor assignments become normalized without review."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "assignments = [\n",
        "    {\"Workspace\": \"FIN-PRD-ANL\", \"Role\": \"Admin\", \"Members\": 3},\n",
        "    {\"Workspace\": \"MKT-PRD-BI\", \"Role\": \"Viewer\", \"Members\": 120},\n",
        "    {\"Workspace\": \"HR-DEV-DS\", \"Role\": \"Contributor\", \"Members\": 8},\n",
        "]\n",
        "\n",
        "thresholds = {\n",
        "    \"Admin\": 5,\n",
        "    \"Contributor\": 25,\n",
        "    \"Viewer\": 100,\n",
        "}\n",
        "\n",
        "for a in assignments:\n",
        "    if a[\"Members\"] > thresholds[a[\"Role\"]]:\n",
        "        print(f\"ALERT: {a['Workspace']} has too many {a['Role']} members ({a['Members']})\")\n",
        "    else:\n",
        "        print(f\"OK: {a['Workspace']} role assignment within threshold\")"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Cross-environment isolation check\n",
        "\n",
        "This validation detects data access paths that cross environment boundaries, such as dev reaching into prod. Basic checks like this catch shortcuts before they become permanent architecture."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "connections = [\n",
        "    {\"source\": \"FIN-DEV-ANL\", \"target\": \"FIN-PRD-WH\"},\n",
        "    {\"source\": \"HR-PRD-DS\", \"target\": \"HR-PRD-LH\"},\n",
        "    {\"source\": \"MKT-TST-BI\", \"target\": \"MKT-DEV-LH\"},\n",
        "]\n",
        "\n",
        "def env(name: str) -> str:\n",
        "    return name.split(\"-\")[1]\n",
        "\n",
        "for c in connections:\n",
        "    if env(c[\"source\"]) != env(c[\"target\"]):\n",
        "        print(f\"VIOLATION: {c['source']} -> {c['target']}\")\n",
        "    else:\n",
        "        print(f\"OK: {c['source']} -> {c['target']}\")"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Capacity health and cost guardrails\n",
        "\n",
        "This example flags hot capacities using CPU and interactive delay. The goal is to identify when shared resources need rebalancing or scaling before user pain and cost complaints pile up."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "capacity_metrics = [\n",
        "    {\"capacity\": \"F64-Prod\", \"cpu_pct\": 72, \"interactive_delay_s\": 4.2},\n",
        "    {\"capacity\": \"F32-Dev\", \"cpu_pct\": 91, \"interactive_delay_s\": 12.8},\n",
        "    {\"capacity\": \"F128-Shared\", \"cpu_pct\": 66, \"interactive_delay_s\": 3.1},\n",
        "]\n",
        "\n",
        "for m in capacity_metrics:\n",
        "    hot = m[\"cpu_pct\"] > 85 or m[\"interactive_delay_s\"] > 10\n",
        "    status = \"SCALE/REBALANCE\" if hot else \"HEALTHY\"\n",
        "    print(f\"{m['capacity']}: CPU={m['cpu_pct']}% Delay={m['interactive_delay_s']}s => {status}\")\n",
        "\n",
        "# Optional tabular view\n",
        "pd.DataFrame(capacity_metrics)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Lifecycle governance for stale workspaces\n",
        "\n",
        "Unused non-production workspaces create cost, confusion, and stale access. This cell identifies non-prod workspaces that should be reviewed for retirement based on inactivity."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "workspaces = [\n",
        "    {\"Name\": \"FIN-PRD-ANL\", \"LastActivityDays\": 12, \"Environment\": \"PRD\"},\n",
        "    {\"Name\": \"OPS-TST-BI\", \"LastActivityDays\": 97, \"Environment\": \"TST\"},\n",
        "    {\"Name\": \"LAB-DEV-DS\", \"LastActivityDays\": 143, \"Environment\": \"DEV\"},\n",
        "]\n",
        "\n",
        "for ws in workspaces:\n",
        "    if ws[\"Environment\"] != \"PRD\" and ws[\"LastActivityDays\"] > 90:\n",
        "        print(f\"RETIRE CANDIDATE: {ws['Name']}\")\n",
        "    else:\n",
        "        print(f\"KEEP: {ws['Name']}\")"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Governance telemetry and oversight flow\n",
        "\n",
        "This final diagram shows the target oversight pattern: telemetry and inventory feed governance rules, which then drive alerts, dashboards, and selective auto-remediation. Start with visibility first, then automate carefully."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {},
      "source": [
        "import matplotlib.pyplot as plt\n",
        "import networkx as nx\n",
        "\n",
        "G = nx.DiGraph()\n",
        "\n",
        "edges = [\n",
        "    (\"Capacity Telemetry\", \"Governance Rules\"),\n",
        "    (\"Workspace Inventory\", \"Governance Rules\"),\n",
        "    (\"Access Assignments\", \"Governance Rules\"),\n",
        "    (\"Artifact Metadata\", \"Governance Rules\"),\n",
        "    (\"Governance Rules\", \"Alerts\"),\n",
        "    (\"Governance Rules\", \"Auto-remediation\"),\n",
        "    (\"Governance Rules\", \"Executive Governance Dashboard\"),\n",
        "]\n",
        "\n",
        "G.add_edges_from(edges)\n",
        "\n",
        "pos = {\n",
        "    \"Capacity Telemetry\": (-2, 1.2),\n",
        "    \"Workspace Inventory\": (-2, 0.4),\n",
        "    \"Access Assignments\": (-2, -0.4),\n",
        "    \"Artifact Metadata\": (-2, -1.2),\n",
        "    \"Governance Rules\": (0, 0),\n",
        "    \"Alerts\": (2, 1),\n",
        "    \"Auto-remediation\": (2, 0),\n",
        "    \"Executive Governance Dashboard\": (2, -1),\n",
        "}\n",
        "\n",
        "plt.figure(figsize=(12, 6))\n",
        "nx.draw(\n",
        "    G,\n",
        "    pos,\n",
        "    with_labels=True,\n",
        "    node_size=3400,\n",
        "    node_color=\"#E8F5E9\",\n",
        "    font_size=9,\n",
        "    arrows=True,\n",
        "    arrowstyle=\"-|>\",\n",
        "    arrowsize=16,\n",
        ")\n",
        "plt.title(\"Governance Telemetry to Action Flow\")\n",
        "plt.axis(\"off\")\n",
        "plt.show()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Summary\n",
        "\n",
        "This notebook translated the blog post into practical governance checks for Microsoft Fabric at scale: naming standards, metadata gates, deployment validation, role-size thresholding, environment isolation, capacity monitoring, and lifecycle review. The common theme is that scale requires delegated authority under explicit guardrails, not just more workspaces and more capacity.\n",
        "\n",
        "## Next Steps\n",
        "\n",
        "- Replace the sample datasets with exports from your Fabric tenant inventory.\n",
        "- Turn the validation logic into CI/CD checks for workspace and artifact promotion.\n",
        "- Add ownership, exception handling, and escalation paths to each rule.\n",
        "- Build a governance dashboard that combines inventory, access drift, lifecycle, and capacity health.\n",
        "- Ask leadership to formally sign off on tenant policy, workspace classes, domain accountability, and cost ownership before expansion."
      ]
    }
  ]
}