0
# Client Management
1
2
Core client initialization, configuration, and authentication for accessing Azure Machine Learning Compute resources. This module provides the main entry point and configuration management for the SDK.
3
4
## Capabilities
5
6
### Management Client
7
8
The primary client class that coordinates all Azure Machine Learning Compute operations. Provides access to specialized operation groups and handles authentication, serialization, and service communication.
9
10
```python { .api }
11
class MachineLearningComputeManagementClient:
12
"""
13
Main client for Azure Machine Learning Compute management operations.
14
15
Args:
16
credentials: Azure credentials object (from azure.identity)
17
subscription_id (str): The Azure subscription ID
18
base_url (str, optional): Service URL, defaults to Azure management endpoint
19
20
Attributes:
21
operationalization_clusters: OperationalizationClustersOperations instance
22
machine_learning_compute: MachineLearningComputeOperations instance
23
config: Client configuration object
24
api_version: "2017-08-01-preview"
25
"""
26
def __init__(self, credentials, subscription_id: str, base_url: str = None): ...
27
28
# Properties
29
operationalization_clusters: OperationalizationClustersOperations
30
machine_learning_compute: MachineLearningComputeOperations
31
config: MachineLearningComputeManagementClientConfiguration
32
api_version: str
33
```
34
35
**Usage Example:**
36
37
```python
38
from azure.identity import DefaultAzureCredential
39
from azure.mgmt.machinelearningcompute import MachineLearningComputeManagementClient
40
41
# Using DefaultAzureCredential (recommended)
42
credential = DefaultAzureCredential()
43
client = MachineLearningComputeManagementClient(
44
credentials=credential,
45
subscription_id="12345678-1234-5678-9012-123456789012"
46
)
47
48
# Using custom base URL
49
client = MachineLearningComputeManagementClient(
50
credentials=credential,
51
subscription_id="12345678-1234-5678-9012-123456789012",
52
base_url="https://management.azure.com"
53
)
54
55
# Access operation groups
56
clusters_ops = client.operationalization_clusters
57
compute_ops = client.machine_learning_compute
58
```
59
60
### Client Configuration
61
62
Configuration class that manages client settings, authentication, and service endpoints. Handles user agent strings, request timeouts, and Azure-specific configuration.
63
64
```python { .api }
65
class MachineLearningComputeManagementClientConfiguration:
66
"""
67
Configuration for MachineLearningComputeManagementClient.
68
69
Args:
70
credentials: Azure credentials object
71
subscription_id (str): The Azure subscription ID
72
base_url (str, optional): Service URL, defaults to Azure management endpoint
73
74
Attributes:
75
credentials: Stored credentials for authentication
76
subscription_id: Azure subscription identifier
77
generate_client_request_id: Whether to generate request IDs
78
accept_language: Accept-Language header value
79
long_running_operation_timeout: Timeout for long-running operations
80
"""
81
def __init__(self, credentials, subscription_id: str, base_url: str = None): ...
82
83
# Configuration properties
84
credentials: object
85
subscription_id: str
86
generate_client_request_id: bool
87
accept_language: str
88
long_running_operation_timeout: int
89
90
def add_user_agent(self, value: str) -> None:
91
"""Add custom user agent string."""
92
```
93
94
**Usage Example:**
95
96
```python
97
from azure.identity import DefaultAzureCredential
98
from azure.mgmt.machinelearningcompute import MachineLearningComputeManagementClientConfiguration
99
100
# Direct configuration usage (rarely needed)
101
credential = DefaultAzureCredential()
102
config = MachineLearningComputeManagementClientConfiguration(
103
credentials=credential,
104
subscription_id="12345678-1234-5678-9012-123456789012"
105
)
106
107
# Access configuration properties
108
print(f"Subscription: {config.subscription_id}")
109
print(f"User agent includes: azure-mgmt-machinelearningcompute/0.4.1")
110
111
# Modify timeout for long-running operations
112
config.long_running_operation_timeout = 600 # 10 minutes
113
```
114
115
## Authentication Patterns
116
117
### Using DefaultAzureCredential (Recommended)
118
119
```python
120
from azure.identity import DefaultAzureCredential
121
from azure.mgmt.machinelearningcompute import MachineLearningComputeManagementClient
122
123
# Automatically uses environment variables, managed identity, or interactive auth
124
credential = DefaultAzureCredential()
125
client = MachineLearningComputeManagementClient(credential, subscription_id)
126
```
127
128
### Using Service Principal
129
130
```python
131
from azure.identity import ClientSecretCredential
132
from azure.mgmt.machinelearningcompute import MachineLearningComputeManagementClient
133
134
credential = ClientSecretCredential(
135
tenant_id="tenant-id",
136
client_id="client-id",
137
client_secret="client-secret"
138
)
139
client = MachineLearningComputeManagementClient(credential, subscription_id)
140
```
141
142
### Using Interactive Authentication
143
144
```python
145
from azure.identity import InteractiveBrowserCredential
146
from azure.mgmt.machinelearningcompute import MachineLearningComputeManagementClient
147
148
credential = InteractiveBrowserCredential()
149
client = MachineLearningComputeManagementClient(credential, subscription_id)
150
```
151
152
## Error Handling
153
154
The client raises exceptions for authentication failures, invalid parameters, and service errors:
155
156
```python
157
from azure.mgmt.machinelearningcompute.models import ErrorResponseWrapperException
158
from azure.core.exceptions import ClientAuthenticationError
159
160
try:
161
cluster = client.operationalization_clusters.get("rg", "cluster")
162
except ClientAuthenticationError:
163
print("Authentication failed - check credentials")
164
except ErrorResponseWrapperException as e:
165
print(f"Service error: {e.message}")
166
except Exception as e:
167
print(f"Unexpected error: {e}")
168
```