A Python wrapper library for Microsoft Fabric (and Power BI) operations, providing a simple interface to the official Fabric REST APIs. Falls back to Power BI REST APIs where needed. Designed to run in Python notebooks, pure Python scripts or integrated into YAML-based workflows for CI/CD. Access to the repositoy on GitHub.
- Authenticate using environment variables (GitHub Secrets, ADO Secrets, AzKeyVault, .env ...)
- Manage workspaces, capacities, semantic models, lakehouses, reports and connections
- Execute Git operations and automate Fabric deployment flows (Power BI inclusive)
- Capture and Manage Git branches automatically for CI/CD scenarios
- Many use cases and scenarios including yaml for test and deploy using GitHub Actions
Access: https://pyfabricops.readthedocs.io/en/latest/
- Requires Python >= 3.10 <=3.12.10
pip install -U pyfabricopsCreate a repository and clone it locally. Create a notebook or a script and import the library:
# Import the library
import pyfabricops as pfSet auth environment variables acording to your authentication method
pf.set_auth_provider("env")This is the default behavior. You can set these in a .env file or directly in your environment (GitHub Secrets, ADO Secrets...).
Example .env file:
FAB_CLIENT_ID=your_client_id_here
FAB_CLIENT_SECRET=your_client_secret_here
FAB_TENANT_ID=your_tenant_id_here
FAB_USERNAME=your_username_here # Necessary for some functions with no SPN support
FAB_PASSWORD=your_password_here # Necessary for some functions with no SPN support
pf.set_auth_provider("vault")Ensure you have the required Azure Key Vault secrets set:
AZURE_CLIENT_ID=your_azure_client_id_here
AZURE_CLIENT_SECRET=your_azure_client_secret_here
AZURE_TENANT_ID=your_azure_tenant_id_here
AZURE_KEY_VAULT_NAME=your_key_vault_name_here
pf.set_auth_provider("oauth")This will open a browser window for user authentication.
Create a repository and clone it locally. Prepare your environment with the required variables according to your authentication method (GitHub Secrets, ADO Secrets, AzKeyVault, .env ...)
Create a branches.json file in the root of your repository to define your branch mappings:
{
"main": "-PRD",
"master": "-PRD",
"dev": "-DEV",
"staging": "-STG"
}This file maps your local branches to Fabric branches, allowing the library to automatically manage branch names for CI/CD scenarios.
Visit: https://github.com/alisonpezzott/pyfabricops-examples
src/
βββ pyfabricops/
βββ api/
β βββ __init__.py
β βββ api.py
β βββ auth.py
β βββ scopes.py
βββ cd/
β βββ __init__.py
β βββ support_files.py
βββ core/
β βββ __init__.py
β βββ capacities.py
β βββ connections.py
β βββ deployment_pipelines.py
β βββ folders.py
β βββ gateways.py
β βββ gateways_encryp_creds.py
β βββ git.py
β βββ workspaces.py
βββ dmv/
β βββ __init__.py
β βββ dmv.py
βββ helpers/
β βββ __init__.py
β βββ dataflows_gen1.py
β βββ dataflows_gen2.py
β βββ data_pipelines.py
β βββ folders.py
β βββ items.py
β βββ lakehouses.py
β βββ notebooks.py
β βββ reports.py
β βββ semantic_models.py
β βββ warehouses.py
β βββ workspaces.py
βββ items/
β βββ __init__.py
β βββ dataflows_gen1.py
β βββ dataflows_gen2.py
β βββ data_pipelines.py
β βββ items.py
β βββ lakehouses.py
β βββ notebooks.py
β βββ reports.py
β βββ semantic_models.py
β βββ shortcuts.py
β βββ warehouses.py
βββ utils/
β βββ __init__.py
β βββ decorators.py
β βββ exceptions.py
β βββ logging.py
β βββ schemas.py
β βββ utils.py
βββ __init__.py
βββ _version.pyThe custom logging system implemented in pyfabricops provides a complete and flexible solution for monitoring and debugging the library.
- Automatic colors: Different colors for each log level (DEBUG=Cyan, INFO=Green, WARNING=Yellow, ERROR=Red, CRITICAL=Magenta)
- Multiple styles:
minimal: Only timestamp, level and messagestandard: Includes module name in compact formdetailed: Complete format with all information
import pyfabricops as pf
# Basic configuration
pf.setup_logging(level='INFO', format_style='standard')
# Debug mode for development
pf.enable_debug_mode(include_external=False)
# Disable logging completely
pf.disable_logging()
# Reset to default configuration
pf.reset_logging()For complete logging configuration options, refer to the logging_system.md
- Fork this repository
- Create a new branch (feat/my-feature)
- Run
poetry installto set up the development environment - Run
poetry run task testto run tests - Submit a pull request π
To publish a new version to PyPI:
- Update the version in
pyproject.tomlandsrc/pyfabricops/_version.py - Commit and push changes
- Create a new release on GitHub with a tag (e.g.,
v0.1.0) - The GitHub Action will automatically:
- Run tests
- Build the package
- Publish to PyPI
# Configure TestPyPI
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry config pypi-token.testpypi <your-testpypi-token>
# Build and publish to TestPyPI
poetry build
poetry publish -r testpypi
# Install from TestPyPI
pip install --index-url https://test.pypi.org/simple/ pyfabricops- Set up a PyPI account at https://pypi.org/
- Generate an API token at https://pypi.org/manage/account/token/
- Add the token as
PYPI_TOKENsecret in GitHub repository settings
If you encounter any issues, please report them at https://github.com/alisonpezzott/pyfabricops/issues
This project is licensed under the MIT License β see the LICENSE file for details.
Created and maintained by Alison Pezzott Feedback, issues and stars are welcome π