Skip to content

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 item_type_in_scope list of the given FabricWorkspace object.

unpublish_all_orphan_items

Unpublishes all orphaned items not present in the repository except for those matching the exclude regex.

FabricWorkspace

FabricWorkspace(
    workspace_id: str,
    repository_directory: str,
    item_type_in_scope: list[str],
    environment: str = "N/A",
    token_credential: TokenCredential = None,
    **kwargs,
)

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
environment str

The environment to be used for parameterization.

'N/A'
token_credential TokenCredential

The token credential to use for API requests.

None
kwargs

Additional keyword arguments.

{}

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"],
...     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_feature_flag

append_feature_flag(feature: str) -> None

Append a feature flag to the global feature_flag set.

Parameters:

Name Type Description Default
feature str

The feature flag to be included.

required

Examples:

Basic usage

>>> from fabric_cicd import append_feature_flag
>>> append_feature_flag("enable_lakehouse_unpublish")

change_log_level

change_log_level(level: str = 'DEBUG') -> None

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 change_log_level
>>> change_log_level("DEBUG")

publish_all_items

publish_all_items(
    fabric_workspace_obj: FabricWorkspace,
    item_name_exclude_regex: Optional[str] = None,
) -> 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
item_name_exclude_regex Optional[str]

Regex pattern to exclude specific items from being published.

None

Examples:

Basic usage

>>> from fabric_cicd import FabricWorkspace, publish_all_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_all_orphan_items

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)