{"id":2946,"library":"fabric-analytics-sdk","title":"Fabric Analytics SDK","description":"The Fabric Analytics SDK for Python provides programmatic access to Microsoft Fabric Analytics services. It allows interaction with datasets, lakehouses, and warehouses within Fabric. The current version is 0.0.3.post1. Given its early 0.0.x versioning and the release patterns typical for new Microsoft SDKs, frequent updates and potential breaking changes are expected.","status":"active","version":"0.0.3.post1","language":"en","source_language":"en","source_url":"https://github.com/microsoft/fabric-analytics-sdk-for-python","tags":["analytics","sdk","microsoft-fabric","azure"],"install":[{"cmd":"pip install fabric-analytics-sdk","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for Azure authentication (e.g., DefaultAzureCredential).","package":"azure-identity","optional":false},{"reason":"Core Azure SDK utilities and exception handling.","package":"azure-core","optional":false},{"reason":"Used for Managed Service Identity operations within Azure authentication.","package":"azure-mgmt-msi","optional":false},{"reason":"Microsoft Authentication Library for Python, used for Azure AD authentication.","package":"msal","optional":false},{"reason":"HTTP client library for making API requests.","package":"requests","optional":false}],"imports":[{"note":"The top-level package for import is 'fabric_analytics', not 'fabric-analytics-sdk'.","symbol":"AnalyticsClient","correct":"from fabric_analytics.analytics_client import AnalyticsClient"},{"note":"Required for authenticating with Azure services.","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"},{"note":"Common exception for when a requested resource is not found.","symbol":"ResourceNotFoundError","correct":"from azure.core.exceptions import ResourceNotFoundError"}],"quickstart":{"code":"import os\nfrom fabric_analytics.analytics_client import AnalyticsClient\nfrom azure.identity import DefaultAzureCredential\nfrom azure.core.exceptions import ResourceNotFoundError\n\n# IMPORTANT: Ensure your environment is configured for Azure authentication.\n# For local development, set environment variables like AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET\n# or use Azure CLI/VS Code login. More info: https://learn.microsoft.com/en-us/azure/developer/python/authentication/managed-identity-sdk-azure-cli\n\ntry:\n    # Initialize DefaultAzureCredential. It attempts various authentication methods.\n    credential = DefaultAzureCredential()\n\n    # Replace with your actual Fabric workspace ID and item ID.\n    # For a runnable example, ensure these environment variables are set.\n    workspace_id = os.environ.get(\"FABRIC_WORKSPACE_ID\", \"<YOUR_FABRIC_WORKSPACE_ID>\")\n    item_id = os.environ.get(\"FABRIC_ITEM_ID\", \"<YOUR_FABRIC_ITEM_ID>\")\n    item_type = os.environ.get(\"FABRIC_ITEM_TYPE\", \"Lakehouse\") # e.g., \"Lakehouse\", \"Warehouse\", \"Dataset\"\n\n    if workspace_id == \"<YOUR_FABRIC_WORKSPACE_ID>\" or item_id == \"<YOUR_FABRIC_ITEM_ID>\":\n        print(\"Please set FABRIC_WORKSPACE_ID and FABRIC_ITEM_ID environment variables, or replace placeholders in the code.\")\n        exit(1)\n\n    client = AnalyticsClient(credential=credential)\n\n    print(f\"Attempting to get item: {item_id} of type {item_type} in workspace {workspace_id}\")\n    # Example: Get a specific Fabric item (e.g., Lakehouse, Warehouse, Dataset)\n    item_info = client.get_item(workspace_id=workspace_id, item_id=item_id, item_type=item_type)\n    print(f\"Successfully retrieved item: {item_info.display_name} (ID: {item_info.id})\")\n    print(f\"Description: {item_info.description or 'No description'}\")\n\n    # Example: List items in a workspace\n    print(f\"\\nListing first 3 items in workspace {workspace_id}:\")\n    items_list_response = client.list_items(workspace_id=workspace_id)\n    if items_list_response.value:\n        for i, item in enumerate(items_list_response.value):\n            if i >= 3:\n                break\n            print(f\"- {item.display_name} (Type: {item.type}, ID: {item.id})\")\n    else:\n        print(\"No items found or insufficient permissions.\")\n\nexcept ResourceNotFoundError as e:\n    print(f\"Error: Resource not found. Please check workspace ID, item ID, item type, and permissions. Details: {e}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n    print(\"Ensure your Azure environment is set up correctly and you have sufficient permissions in Fabric.\")","lang":"python","description":"This quickstart demonstrates how to initialize the Fabric Analytics client using `DefaultAzureCredential` and retrieve basic information about a Fabric item (like a Lakehouse) within a specified workspace. It also shows how to list items in a workspace. Remember to replace placeholder IDs or set them as environment variables and ensure proper Azure authentication and Fabric permissions."},"warnings":[{"fix":"Always pin to exact versions (`fabric-analytics-sdk==0.0.3.post1`) in your `requirements.txt` or `pyproject.toml` and thoroughly review release notes/changelogs for each update before upgrading.","message":"As a pre-release library (version 0.0.x), the API surface is considered unstable. Breaking changes, renames, and removals can occur in any minor or patch release without prior deprecation warnings. Applications using this SDK should be prepared for frequent updates and potential rewrites.","severity":"breaking","affected_versions":"0.0.x series"},{"fix":"Refer to the `azure-identity` documentation for configuring `DefaultAzureCredential` for your specific environment. Ensure your principal has the necessary roles in Microsoft Fabric.","message":"Authenticating with Azure services requires proper setup of `DefaultAzureCredential`. This often involves setting environment variables (`AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`), logging in via Azure CLI (`az login`), or configuring Managed Identities. Incorrect setup is a common cause of `AuthenticationFailedError` or similar credential errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify that the Azure AD principal used for authentication has the appropriate roles and permissions assigned in the Microsoft Fabric workspace and to the specific items where operations are being performed.","message":"Even with correct authentication, operations will fail if the authenticated principal lacks the required permissions (e.g., 'Fabric Admin', 'Contributor', 'Viewer', or specific item permissions) within the specific Fabric workspace or item. Errors like `ResourceNotFoundError` or `Unauthorized` can stem from insufficient permissions.","severity":"gotcha","affected_versions":"All versions"},{"fix":"After `pip install fabric-analytics-sdk`, remember to use `from fabric_analytics.<module> import <Class>` for your imports.","message":"The PyPI package name is `fabric-analytics-sdk`, but the top-level import for the library is `fabric_analytics`. This difference in naming convention can sometimes lead to confusion for new users trying to import modules.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}