WorkspaceOperations Class
Handles workspaces and its subclasses, hubs and projects.
You should not instantiate this class directly. Instead, you should create an MLClient instance that instantiates it for you and attaches it as an attribute.
- Inheritance
-
azure.ai.ml.operations._workspace_operations_base.WorkspaceOperationsBaseWorkspaceOperations
Constructor
WorkspaceOperations(operation_scope: OperationScope, service_client: AzureMachineLearningWorkspaces, all_operations: OperationsContainer, credentials: TokenCredential | None = None, **kwargs: Any)
Parameters
Name | Description |
---|---|
operation_scope
Required
|
|
service_client
Required
|
|
all_operations
Required
|
|
credentials
|
Default value: None
|
Methods
begin_create |
Create a new Azure Machine Learning Workspace. Returns the workspace if already exists. |
begin_delete |
Delete a workspace. |
begin_diagnose |
Diagnose workspace setup problems. If your workspace is not working as expected, you can run this diagnosis to check if the workspace has been broken. For private endpoint workspace, it will also help check if the network setup to this workspace and its dependent resource has problems or not. |
begin_provision_network |
Triggers the workspace to provision the managed network. Specifying spark enabled as true prepares the workspace managed network for supporting Spark. |
begin_sync_keys |
Triggers the workspace to immediately synchronize keys. If keys for any resource in the workspace are changed, it can take around an hour for them to automatically be updated. This function enables keys to be updated upon request. An example scenario is needing immediate access to storage after regenerating storage keys. |
begin_update |
Updates a Azure Machine Learning Workspace. |
get |
Get a Workspace by name. |
get_keys |
Get WorkspaceKeys by workspace name. |
list |
List all Workspaces that the user has access to in the current resource group or subscription. |
begin_create
Create a new Azure Machine Learning Workspace.
Returns the workspace if already exists.
begin_create(workspace: Workspace, update_dependent_resources: bool = False, **kwargs: Any) -> LROPoller[Workspace]
Parameters
Name | Description |
---|---|
workspace
Required
|
Workspace definition. |
update_dependent_resources
Required
|
<xref:boolean>
Whether to update dependent resources, defaults to False. |
Returns
Type | Description |
---|---|
An instance of LROPoller that returns a Workspace. |
Examples
Begin create for a workspace.
from azure.ai.ml.entities import Workspace
ws = Workspace(
name="test-ws1",
description="a test workspace",
tags={"purpose": "demo"},
location="eastus",
resource_group=resource_group,
)
ws = ml_client.workspaces.begin_create(workspace=ws).result()
begin_delete
Delete a workspace.
begin_delete(name: str, *, delete_dependent_resources: bool, permanently_delete: bool = False, **kwargs: Dict) -> LROPoller[None]
Parameters
Name | Description |
---|---|
name
Required
|
Name of the workspace |
Keyword-Only Parameters
Name | Description |
---|---|
delete_dependent_resources
|
Whether to delete resources associated with the workspace, i.e., container registry, storage account, key vault, application insights, log analytics. The default is False. Set to True to delete these resources. |
permanently_delete
|
Workspaces are soft-deleted by default to allow recovery of workspace data. Set this flag to true to override the soft-delete behavior and permanently delete your workspace. |
Returns
Type | Description |
---|---|
A poller to track the operation status. |
Examples
Begin permanent (force) deletion for a workspace and delete dependent resources.
ml_client.workspaces.begin_delete(name="test-ws", delete_dependent_resources=True, permanently_delete=True)
begin_diagnose
Diagnose workspace setup problems.
If your workspace is not working as expected, you can run this diagnosis to check if the workspace has been broken. For private endpoint workspace, it will also help check if the network setup to this workspace and its dependent resource has problems or not.
begin_diagnose(name: str, **kwargs: Dict) -> LROPoller[DiagnoseResponseResultValue]
Parameters
Name | Description |
---|---|
name
Required
|
Name of the workspace |
Returns
Type | Description |
---|---|
A poller to track the operation status. |
Examples
Begin diagnose operation for a workspace.
diagnose_result = ml_client.workspaces.begin_diagnose(name="test-ws1").result()
begin_provision_network
Triggers the workspace to provision the managed network. Specifying spark enabled as true prepares the workspace managed network for supporting Spark.
begin_provision_network(*, workspace_name: str | None = None, include_spark: bool = False, **kwargs: Any) -> LROPoller[ManagedNetworkProvisionStatus]
Keyword-Only Parameters
Name | Description |
---|---|
workspace_name
|
Name of the workspace. |
include_spark
|
Whether the workspace managed network should prepare to support Spark. |
Returns
Type | Description |
---|---|
An instance of LROPoller. |
Examples
Begin provision network for a workspace with managed network.
ml_client.workspaces.begin_provision_network(workspace_name="test-ws1", include_spark=False)
begin_sync_keys
Triggers the workspace to immediately synchronize keys. If keys for any resource in the workspace are changed, it can take around an hour for them to automatically be updated. This function enables keys to be updated upon request. An example scenario is needing immediate access to storage after regenerating storage keys.
begin_sync_keys(name: str | None = None) -> LROPoller[None]
Parameters
Name | Description |
---|---|
name
Required
|
Name of the workspace. |
Returns
Type | Description |
---|---|
An instance of LROPoller that returns either None or the sync keys result. |
Examples
Begin sync keys for the workspace with the given name.
ml_client.workspaces.begin_sync_keys(name="test-ws1")
begin_update
Updates a Azure Machine Learning Workspace.
begin_update(workspace: Workspace, *, update_dependent_resources: bool = False, **kwargs: Any) -> LROPoller[Workspace]
Parameters
Name | Description |
---|---|
workspace
Required
|
Workspace definition. |
Keyword-Only Parameters
Name | Description |
---|---|
update_dependent_resources
|
<xref:boolean>
Whether to update dependent resources, defaults to False. |
Returns
Type | Description |
---|---|
An instance of LROPoller that returns a Workspace. |
Examples
Begin update for a workspace.
ws = ml_client.workspaces.get(name="test-ws1")
ws.description = "a different description"
ws = ml_client.workspaces.begin_update(workspace=ws).result()
get
Get a Workspace by name.
get(name: str | None = None, **kwargs: Dict) -> Workspace | None
Parameters
Name | Description |
---|---|
name
Required
|
Name of the workspace. |
Returns
Type | Description |
---|---|
The workspace with the provided name. |
Examples
Get the workspace with the given name.
workspace = ml_client.workspaces.get(name="test-ws1")
get_keys
Get WorkspaceKeys by workspace name.
get_keys(name: str | None = None) -> WorkspaceKeys | None
Parameters
Name | Description |
---|---|
name
Required
|
Name of the workspace. |
Returns
Type | Description |
---|---|
Keys of workspace dependent resources. |
Examples
Get the workspace keys for the workspace with the given name.
ws_keys = ml_client.workspaces.get_keys(name="test-ws1")
list
List all Workspaces that the user has access to in the current resource group or subscription.
list(*, scope: str = 'resource_group', filtered_kinds: str | List[str] | None = None) -> Iterable[Workspace]
Keyword-Only Parameters
Name | Description |
---|---|
scope
|
scope of the listing, "resource_group" or "subscription", defaults to "resource_group" |
filtered_kinds
|
The kinds of workspaces to list. If not provided, all workspaces varieties will be listed. Accepts either a single kind, or a list of them. Valid kind options include: "default", "project", and "hub". |
Returns
Type | Description |
---|---|
An iterator like instance of Workspace objects |
Examples
List the workspaces by resource group or subscription.
from azure.ai.ml.constants import Scope
# list workspaces in the resource group set in ml_client
workspaces = ml_client.workspaces.list()
workspaces = ml_client.workspaces.list(scope=Scope.RESOURCE_GROUP)
# list workspaces in the subscription set in ml_client
workspaces = ml_client.workspaces.list(scope=Scope.SUBSCRIPTION)
Azure SDK for Python