WorkspaceConnectionsOperations Class

WorkspaceConnectionsOperations.

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._scope_dependent_operations._ScopeDependentOperations
WorkspaceConnectionsOperations

Constructor

WorkspaceConnectionsOperations(operation_scope: OperationScope, operation_config: OperationConfig, service_client: AzureMachineLearningWorkspaces, all_operations: OperationsContainer, credentials: TokenCredential | None = None, **kwargs: Dict)

Parameters

Name Description
operation_scope
Required
operation_config
Required
service_client
Required
all_operations
Required
credentials
default value: None

Methods

create_or_update

Create or update a workspace connection.

delete

Delete the workspace connection.

get

Get a workspace connection by name.

list

List all workspace connections for a workspace.

create_or_update

Create or update a workspace connection.

create_or_update(workspace_connection: WorkspaceConnection, **kwargs: Any) -> WorkspaceConnection | None

Parameters

Name Description
workspace_connection
Required

Workspace Connection definition or object which can be translated to a workspace connection.

Returns

Type Description

Created or update workspace connection.

Examples

Create or update a workspace connection, this example shows snowflake.


   from azure.ai.ml import MLClient
   from azure.ai.ml.entities import WorkspaceConnection
   from azure.ai.ml.entities import UsernamePasswordConfiguration

   ml_client_ws = MLClient(credential, subscription_id, resource_group, workspace_name="test-ws")
   wps_connection = WorkspaceConnection(
       name="connection-1",
       type="snowflake",
       target="jdbc:snowflake://<myaccount>.snowflakecomputing.com/?db=<mydb>&warehouse=<mywarehouse>&role=<myrole>",  # cspell:disable-line
       credentials=UsernamePasswordConfiguration(username="XXXXX", password="XXXXXX"),
   )
   connection = ml_client_ws.connections.create_or_update(workspace_connection=wps_connection)

delete

Delete the workspace connection.

delete(name: str) -> None

Parameters

Name Description
name
Required
str

Name of the workspace connection.

Examples

Delete a workspace connection.


   from azure.ai.ml import MLClient

   ml_client_ws = MLClient(credential, subscription_id, resource_group, workspace_name="test-ws")
   ml_client_ws.connections.delete(name="connection-1")

get

Get a workspace connection by name.

get(name: str, **kwargs: Dict) -> WorkspaceConnection

Parameters

Name Description
name
Required
str

Name of the workspace connection.

Returns

Type Description

The workspace connection with the provided name.

Exceptions

Type Description

Raised if the corresponding name and version cannot be retrieved from the service.

Examples

Get a workspace connection by name.


   from azure.ai.ml import MLClient

   ml_client_ws = MLClient(credential, subscription_id, resource_group, workspace_name="test-ws1")
   connection = ml_client.connections.get(name="test-ws1")

list

List all workspace connections for a workspace.

list(connection_type: str | None = None, *, include_data_connections: bool = False, **kwargs: Any) -> Iterable[WorkspaceConnection]

Parameters

Name Description
connection_type
Required

Type of workspace connection to list.

Keyword-Only Parameters

Name Description
include_data_connections

If true, also return data connections. Defaults to False.

Returns

Type Description

An iterator like instance of workspace connection objects

Examples

Lists all connections for a workspace for a certain type, in this case "git".


   from azure.ai.ml import MLClient

   ml_client_ws = MLClient(credential, subscription_id, resource_group, workspace_name="test-ws")
   ml_client_ws.connections.list(connection_type="git")