0
# Cluster Operations
1
2
Complete lifecycle management of operationalization clusters including creation, updates, deletion, credential management, and system services. These operations enable full control over Azure Machine Learning compute resources.
3
4
## Capabilities
5
6
### Cluster Lifecycle Management
7
8
Core operations for creating, retrieving, updating, and deleting operationalization clusters.
9
10
```python { .api }
11
class OperationalizationClustersOperations:
12
"""Operations for managing operationalization clusters."""
13
14
def create_or_update(
15
self,
16
resource_group_name: str,
17
cluster_name: str,
18
parameters: OperationalizationCluster,
19
custom_headers: Dict[str, str] = None,
20
raw: bool = False
21
) -> AzureOperationPoller[OperationalizationCluster]:
22
"""
23
Create or update an operationalization cluster.
24
25
Args:
26
resource_group_name (str): Name of the resource group in which the cluster is located
27
cluster_name (str): The name of the cluster
28
parameters (OperationalizationCluster): Parameters supplied to create or update cluster
29
custom_headers (dict, optional): Headers to add to the request
30
raw (bool): Returns direct response alongside deserialized response
31
32
Returns:
33
AzureOperationPoller that returns OperationalizationCluster when complete
34
35
Raises:
36
ErrorResponseWrapperException: Service error occurred
37
"""
38
39
def get(
40
self,
41
resource_group_name: str,
42
cluster_name: str,
43
custom_headers: Dict[str, str] = None,
44
raw: bool = False
45
) -> OperationalizationCluster:
46
"""
47
Gets the operationalization cluster resource view.
48
Note: credentials are not returned by this call, use list_keys to get them.
49
50
Args:
51
resource_group_name (str): Name of the resource group in which the cluster is located
52
cluster_name (str): The name of the cluster
53
custom_headers (dict, optional): Headers to add to the request
54
raw (bool): Returns direct response alongside deserialized response
55
56
Returns:
57
OperationalizationCluster: The cluster resource
58
59
Raises:
60
ErrorResponseWrapperException: Service error occurred
61
"""
62
63
def update(
64
self,
65
resource_group_name: str,
66
cluster_name: str,
67
tags: Dict[str, str] = None,
68
custom_headers: Dict[str, str] = None,
69
raw: bool = False
70
) -> OperationalizationCluster:
71
"""
72
Update cluster tags. Use PUT operation to update other properties.
73
74
Args:
75
resource_group_name (str): Name of the resource group in which the cluster is located
76
cluster_name (str): The name of the cluster
77
tags (dict, optional): Resource tags (maximum 15 tags, key ≤128 chars, value ≤256 chars)
78
custom_headers (dict, optional): Headers to add to the request
79
raw (bool): Returns direct response alongside deserialized response
80
81
Returns:
82
OperationalizationCluster: The updated cluster resource
83
84
Raises:
85
ErrorResponseWrapperException: Service error occurred
86
"""
87
88
def delete(
89
self,
90
resource_group_name: str,
91
cluster_name: str,
92
delete_all: bool = None,
93
custom_headers: Dict[str, str] = None,
94
raw: bool = False
95
) -> AzureOperationPoller[None]:
96
"""
97
Deletes the specified cluster.
98
99
Args:
100
resource_group_name (str): Name of the resource group in which the cluster is located
101
cluster_name (str): The name of the cluster
102
delete_all (bool, optional): If true, deletes all resources associated with this cluster
103
custom_headers (dict, optional): Headers to add to the request
104
raw (bool): Returns direct response alongside deserialized response
105
106
Returns:
107
AzureOperationPoller that returns None when complete
108
109
Raises:
110
ErrorResponseWrapperException: Service error occurred
111
"""
112
```
113
114
**Usage Examples:**
115
116
```python
117
from azure.mgmt.machinelearningcompute.models import (
118
OperationalizationCluster,
119
ClusterType,
120
StorageAccountProperties,
121
AcsClusterProperties
122
)
123
124
# Create a simple local cluster
125
local_cluster = OperationalizationCluster(
126
location="eastus",
127
cluster_type=ClusterType.local,
128
description="Development cluster",
129
storage_account=StorageAccountProperties(
130
resource_id="/subscriptions/.../storageAccounts/devstorage"
131
)
132
)
133
134
# Create the cluster (long-running operation)
135
create_operation = client.operationalization_clusters.create_or_update(
136
resource_group_name="dev-rg",
137
cluster_name="dev-cluster",
138
parameters=local_cluster
139
)
140
cluster = create_operation.result() # Wait for completion
141
142
# Get cluster details
143
cluster = client.operationalization_clusters.get("dev-rg", "dev-cluster")
144
print(f"Cluster status: {cluster.provisioning_state}")
145
146
# Update cluster tags
147
updated_cluster = client.operationalization_clusters.update(
148
resource_group_name="dev-rg",
149
cluster_name="dev-cluster",
150
tags={"environment": "development", "owner": "ml-team"}
151
)
152
153
# Delete cluster and all associated resources
154
delete_operation = client.operationalization_clusters.delete(
155
resource_group_name="dev-rg",
156
cluster_name="dev-cluster",
157
delete_all=True
158
)
159
delete_operation.wait() # Wait for completion
160
```
161
162
### Cluster Listing Operations
163
164
Operations for discovering clusters across resource groups and subscriptions.
165
166
```python { .api }
167
def list_by_resource_group(
168
self,
169
resource_group_name: str,
170
skiptoken: str = None,
171
custom_headers: Dict[str, str] = None,
172
raw: bool = False
173
) -> OperationalizationClusterPaged:
174
"""
175
Gets the clusters in the specified resource group.
176
177
Args:
178
resource_group_name (str): Name of the resource group in which the cluster is located
179
skiptoken (str, optional): Continuation token for pagination
180
custom_headers (dict, optional): Headers to add to the request
181
raw (bool): Returns direct response alongside deserialized response
182
183
Returns:
184
OperationalizationClusterPaged: Paginated collection of clusters
185
186
Raises:
187
CloudError: Service error occurred
188
"""
189
190
def list_by_subscription_id(
191
self,
192
skiptoken: str = None,
193
custom_headers: Dict[str, str] = None,
194
raw: bool = False
195
) -> OperationalizationClusterPaged:
196
"""
197
Gets the operationalization clusters in the specified subscription.
198
199
Args:
200
skiptoken (str, optional): Continuation token for pagination
201
custom_headers (dict, optional): Headers to add to the request
202
raw (bool): Returns direct response alongside deserialized response
203
204
Returns:
205
OperationalizationClusterPaged: Paginated collection of clusters
206
207
Raises:
208
CloudError: Service error occurred
209
"""
210
```
211
212
**Usage Examples:**
213
214
```python
215
# List all clusters in a resource group
216
clusters = client.operationalization_clusters.list_by_resource_group("prod-rg")
217
for cluster in clusters:
218
print(f"Cluster: {cluster.name}, Status: {cluster.provisioning_state}")
219
220
# List all clusters in the subscription
221
all_clusters = client.operationalization_clusters.list_by_subscription_id()
222
for cluster in all_clusters:
223
print(f"Cluster: {cluster.name} in RG: {cluster.id.split('/')[4]}")
224
225
# Handle pagination manually if needed
226
clusters_page = client.operationalization_clusters.list_by_resource_group("large-rg")
227
first_10 = list(clusters_page)[:10]
228
```
229
230
### Credential Management
231
232
Operations for retrieving cluster access credentials for storage, container registry, and container service components.
233
234
```python { .api }
235
def list_keys(
236
self,
237
resource_group_name: str,
238
cluster_name: str,
239
custom_headers: Dict[str, str] = None,
240
raw: bool = False
241
) -> OperationalizationClusterCredentials:
242
"""
243
Gets the credentials for the specified cluster such as Storage, ACR and ACS credentials.
244
This is a long running operation because it fetches keys from dependencies.
245
246
Args:
247
resource_group_name (str): Name of the resource group in which the cluster is located
248
cluster_name (str): The name of the cluster
249
custom_headers (dict, optional): Headers to add to the request
250
raw (bool): Returns direct response alongside deserialized response
251
252
Returns:
253
OperationalizationClusterCredentials: Cluster access credentials
254
255
Raises:
256
CloudError: Service error occurred
257
"""
258
```
259
260
**Usage Example:**
261
262
```python
263
# Get cluster credentials
264
credentials = client.operationalization_clusters.list_keys("prod-rg", "prod-cluster")
265
266
# Access different credential types
267
if credentials.storage_account:
268
print(f"Storage account key: {credentials.storage_account.primary_key}")
269
270
if credentials.container_registry:
271
print(f"Registry username: {credentials.container_registry.username}")
272
273
if credentials.container_service:
274
print(f"Kube config available: {bool(credentials.container_service.kube_config)}")
275
```
276
277
### System Services Management
278
279
Operations for managing system services within clusters, including update checking and service updates.
280
281
```python { .api }
282
def check_system_services_updates_available(
283
self,
284
resource_group_name: str,
285
cluster_name: str,
286
custom_headers: Dict[str, str] = None,
287
raw: bool = False
288
) -> CheckSystemServicesUpdatesAvailableResponse:
289
"""
290
Checks if updates are available for system services in the cluster.
291
292
Args:
293
resource_group_name (str): Name of the resource group in which the cluster is located
294
cluster_name (str): The name of the cluster
295
custom_headers (dict, optional): Headers to add to the request
296
raw (bool): Returns direct response alongside deserialized response
297
298
Returns:
299
CheckSystemServicesUpdatesAvailableResponse: Update availability information
300
301
Raises:
302
CloudError: Service error occurred
303
"""
304
305
def update_system_services(
306
self,
307
resource_group_name: str,
308
cluster_name: str,
309
custom_headers: Dict[str, str] = None,
310
raw: bool = False
311
) -> AzureOperationPoller[UpdateSystemServicesResponse]:
312
"""
313
Updates system services in a cluster.
314
315
Args:
316
resource_group_name (str): Name of the resource group in which the cluster is located
317
cluster_name (str): The name of the cluster
318
custom_headers (dict, optional): Headers to add to the request
319
raw (bool): Returns direct response alongside deserialized response
320
321
Returns:
322
AzureOperationPoller that returns UpdateSystemServicesResponse when complete
323
324
Raises:
325
CloudError: Service error occurred
326
"""
327
```
328
329
**Usage Examples:**
330
331
```python
332
# Check for system service updates
333
update_check = client.operationalization_clusters.check_system_services_updates_available(
334
"prod-rg", "prod-cluster"
335
)
336
337
if update_check.updates_available == "Yes":
338
print("Updates are available")
339
340
# Apply system service updates (long-running operation)
341
update_operation = client.operationalization_clusters.update_system_services(
342
"prod-rg", "prod-cluster"
343
)
344
345
# Wait for update completion
346
update_result = update_operation.result()
347
print(f"Update status: {update_result.update_status}")
348
else:
349
print("No updates available")
350
```
351
352
## Long-Running Operations
353
354
Many cluster operations are long-running and return `AzureOperationPoller` objects:
355
356
```python
357
# Start a long-running operation
358
operation = client.operationalization_clusters.create_or_update(rg, name, params)
359
360
# Wait for completion (blocking)
361
result = operation.result()
362
363
# Check if operation is done (non-blocking)
364
if operation.done():
365
result = operation.result()
366
else:
367
print("Still in progress...")
368
369
# Wait with timeout
370
try:
371
result = operation.result(timeout=600) # 10 minutes
372
except Exception as e:
373
print(f"Operation timed out: {e}")
374
```