Code Reference¶
Provides tools for managing and publishing items in a Fabric workspace.
Classes:
| Name | Description | 
|---|---|
| FabricWorkspace | A class to manage and publish workspace items to the Fabric API. | 
Functions:
| Name | Description | 
|---|---|
| append_feature_flag | Append a feature flag to the global feature_flag set. | 
| change_log_level | Sets the log level for all loggers within the fabric_cicd package. Currently only supports DEBUG. | 
| publish_all_items | Publishes all items defined in the  | 
| unpublish_all_orphan_items | Unpublishes all orphaned items not present in the repository except for those matching the exclude regex. | 
 
 FabricWorkspace(
    workspace_id: str,
    repository_directory: str,
    item_type_in_scope: list[str],
    base_api_url: str = "https://api.fabric.microsoft.com/",
    environment: str = "N/A",
    token_credential: TokenCredential = None,
)
A class to manage and publish workspace items to the Fabric API.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| workspace_id | str | The ID of the workspace to interact with. | required | 
| repository_directory | str | Local directory path of the repository where items are to be deployed from. | required | 
| item_type_in_scope | list[str] | Item types that should be deployed for a given workspace. | required | 
| base_api_url | str | Base URL for the Fabric API. Defaults to the Fabric API endpoint. | 'https://api.fabric.microsoft.com/' | 
| environment | str | The environment to be used for parameterization. | 'N/A' | 
| token_credential | TokenCredential | The token credential to use for API requests. | None | 
Examples:
Basic usage
>>> from fabric_cicd import FabricWorkspace
>>> workspace = FabricWorkspace(
...     workspace_id="your-workspace-id",
...     repository_directory="/path/to/repo",
...     item_type_in_scope=["Environment", "Notebook", "DataPipeline"]
... )
With optional parameters
>>> from fabric_cicd import FabricWorkspace
>>> workspace = FabricWorkspace(
...     workspace_id="your-workspace-id",
...     repository_directory="/your/path/to/repo",
...     item_type_in_scope=["Environment", "Notebook", "DataPipeline"],
...     base_api_url="https://orgapi.fabric.microsoft.com",
...     environment="your-target-environment"
... )
With token credential
>>> from fabric_cicd import FabricWorkspace
>>> from azure.identity import ClientSecretCredential
>>> client_id = "your-client-id"
>>> client_secret = "your-client-secret"
>>> tenant_id = "your-tenant-id"
>>> token_credential = ClientSecretCredential(
...     client_id=client_id, client_secret=client_secret, tenant_id=tenant_id
... )
>>> workspace = FabricWorkspace(
...     workspace_id="your-workspace-id",
...     repository_directory="/your/path/to/repo",
...     item_type_in_scope=["Environment", "Notebook", "DataPipeline"],
...     token_credential=token_credential
... )
 
  Append a feature flag to the global feature_flag set.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| feature | str | The feature flag to be included. | required | 
 
  Sets the log level for all loggers within the fabric_cicd package. Currently only supports DEBUG.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| level | str | The logging level to set (e.g., DEBUG). | 'DEBUG' | 
Examples:
Basic usage
>>> from fabric_cicd import FabricWorkspace, publish_all_items, unpublish_all_orphan_items, change_log_level
>>> change_log_level("DEBUG")
>>> workspace = FabricWorkspace(
...     workspace_id="your-workspace-id",
...     repository_directory="/path/to/repo",
...     item_type_in_scope=["Environment", "Notebook", "DataPipeline"]
... )
>>> publish_all_items(workspace)
>>> unpublish_orphaned_items(workspace)
 
 publish_all_items(fabric_workspace_obj: FabricWorkspace) -> None
Publishes all items defined in the item_type_in_scope list of the given FabricWorkspace object.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| fabric_workspace_obj | FabricWorkspace | The FabricWorkspace object containing the items to be published. | required | 
Examples:
Basic usage
 
 unpublish_all_orphan_items(
    fabric_workspace_obj: FabricWorkspace, item_name_exclude_regex: str = "^$"
) -> None
Unpublishes all orphaned items not present in the repository except for those matching the exclude regex.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| fabric_workspace_obj | FabricWorkspace | The FabricWorkspace object containing the items to be published. | required | 
| item_name_exclude_regex | str | Regex pattern to exclude specific items from being unpublished. Default is '^$' which will exclude nothing. | '^$' | 
Examples:
Basic usage
>>> from fabric_cicd import FabricWorkspace, publish_all_items, unpublish_all_orphan_items
>>> workspace = FabricWorkspace(
...     workspace_id="your-workspace-id",
...     repository_directory="/path/to/repo",
...     item_type_in_scope=["Environment", "Notebook", "DataPipeline"]
... )
>>> publish_all_items(workspace)
>>> unpublish_orphaned_items(workspace)
With regex name exclusion
>>> from fabric_cicd import FabricWorkspace, publish_all_items, unpublish_all_orphan_items
>>> workspace = FabricWorkspace(
...     workspace_id="your-workspace-id",
...     repository_directory="/path/to/repo",
...     item_type_in_scope=["Environment", "Notebook", "DataPipeline"]
... )
>>> publish_all_items(workspace)
>>> exclude_regex = ".*_do_not_delete"
>>> unpublish_orphaned_items(workspace, exclude_regex)