0
# Compute Node Operations
1
2
Compute node management capabilities for managing individual virtual machines within pools, including user management, remote access, and node maintenance operations. Compute nodes are the actual virtual machines that execute batch tasks.
3
4
## Capabilities
5
6
### Node Information and Listing
7
8
Retrieve information about compute nodes within pools.
9
10
```python { .api }
11
def list(pool_id, compute_node_list_options=None, custom_headers=None, raw=False, **operation_config):
12
"""
13
List compute nodes in the specified pool.
14
15
Args:
16
pool_id: ID of the pool containing the nodes
17
compute_node_list_options: Additional options for listing
18
19
Returns:
20
ItemPaged[ComputeNode]: Paginated list of compute nodes
21
"""
22
23
def get(pool_id, node_id, compute_node_get_options=None, custom_headers=None, raw=False, **operation_config):
24
"""
25
Get information about the specified compute node.
26
27
Args:
28
pool_id: ID of the pool containing the node
29
node_id: ID of the compute node to retrieve
30
compute_node_get_options: Additional options for the operation
31
32
Returns:
33
ComputeNode: Compute node information
34
"""
35
```
36
37
### User Management
38
39
Manage user accounts on compute nodes for remote access and task execution.
40
41
```python { .api }
42
def add_user(pool_id, node_id, user, compute_node_add_user_options=None, custom_headers=None, raw=False, **operation_config):
43
"""
44
Add a user account to the specified compute node.
45
46
Args:
47
pool_id: ID of the pool containing the node
48
node_id: ID of the compute node
49
user: User account to add (ComputeNodeUser)
50
compute_node_add_user_options: Additional options
51
52
Returns:
53
None
54
"""
55
56
def delete_user(pool_id, node_id, user_name, compute_node_delete_user_options=None, custom_headers=None, raw=False, **operation_config):
57
"""
58
Delete a user account from the specified compute node.
59
60
Args:
61
pool_id: ID of the pool containing the node
62
node_id: ID of the compute node
63
user_name: Name of the user account to delete
64
compute_node_delete_user_options: Additional options
65
66
Returns:
67
None
68
"""
69
70
def update_user(pool_id, node_id, user_name, node_update_user_parameter, compute_node_update_user_options=None, custom_headers=None, raw=False, **operation_config):
71
"""
72
Update properties of a user account on the specified compute node.
73
74
Args:
75
pool_id: ID of the pool containing the node
76
node_id: ID of the compute node
77
user_name: Name of the user account to update
78
node_update_user_parameter: Properties to update
79
compute_node_update_user_options: Additional options
80
81
Returns:
82
None
83
"""
84
```
85
86
### Node Maintenance Operations
87
88
Perform maintenance operations on compute nodes including reboot and reimage.
89
90
```python { .api }
91
def reboot(pool_id, node_id, node_reboot_parameter=None, compute_node_reboot_options=None, custom_headers=None, raw=False, **operation_config):
92
"""
93
Restart the specified compute node.
94
95
Args:
96
pool_id: ID of the pool containing the node
97
node_id: ID of the compute node to reboot
98
node_reboot_parameter: Reboot parameters including reboot type
99
compute_node_reboot_options: Additional options
100
101
Returns:
102
None
103
"""
104
105
def reimage(pool_id, node_id, node_reimage_parameter=None, compute_node_reimage_options=None, custom_headers=None, raw=False, **operation_config):
106
"""
107
Reinstall the operating system on the specified compute node.
108
109
Args:
110
pool_id: ID of the pool containing the node
111
node_id: ID of the compute node to reimage
112
node_reimage_parameter: Reimage parameters including reimage type
113
compute_node_reimage_options: Additional options
114
115
Returns:
116
None
117
"""
118
```
119
120
### Task Scheduling Control
121
122
Control task scheduling on compute nodes.
123
124
```python { .api }
125
def disable_scheduling(pool_id, node_id, node_disable_scheduling_parameter=None, compute_node_disable_scheduling_options=None, custom_headers=None, raw=False, **operation_config):
126
"""
127
Disable task scheduling on the specified compute node.
128
129
Args:
130
pool_id: ID of the pool containing the node
131
node_id: ID of the compute node
132
node_disable_scheduling_parameter: Parameters for disabling scheduling
133
compute_node_disable_scheduling_options: Additional options
134
135
Returns:
136
None
137
"""
138
139
def enable_scheduling(pool_id, node_id, compute_node_enable_scheduling_options=None, custom_headers=None, raw=False, **operation_config):
140
"""
141
Enable task scheduling on the specified compute node.
142
143
Args:
144
pool_id: ID of the pool containing the node
145
node_id: ID of the compute node
146
compute_node_enable_scheduling_options: Additional options
147
148
Returns:
149
None
150
"""
151
```
152
153
### Remote Access
154
155
Get remote access information for compute nodes.
156
157
```python { .api }
158
def get_remote_login_settings(pool_id, node_id, compute_node_get_remote_login_settings_options=None, custom_headers=None, raw=False, **operation_config):
159
"""
160
Get remote login settings for the specified compute node.
161
162
Args:
163
pool_id: ID of the pool containing the node
164
node_id: ID of the compute node
165
compute_node_get_remote_login_settings_options: Additional options
166
167
Returns:
168
ComputeNodeGetRemoteLoginSettingsResult: Remote login settings
169
"""
170
171
def get_remote_desktop(pool_id, node_id, compute_node_get_remote_desktop_options=None, custom_headers=None, raw=False, **operation_config):
172
"""
173
Get Remote Desktop Protocol file for the specified compute node.
174
175
Args:
176
pool_id: ID of the pool containing the node
177
node_id: ID of the compute node
178
compute_node_get_remote_desktop_options: Additional options
179
180
Returns:
181
Stream: RDP file content
182
"""
183
```
184
185
### Log Management
186
187
Upload batch service logs from compute nodes.
188
189
```python { .api }
190
def upload_batch_service_logs(pool_id, node_id, upload_batch_service_logs_configuration, compute_node_upload_batch_service_logs_options=None, custom_headers=None, raw=False, **operation_config):
191
"""
192
Upload Azure Batch service log files from the specified compute node.
193
194
Args:
195
pool_id: ID of the pool containing the node
196
node_id: ID of the compute node
197
upload_batch_service_logs_configuration: Configuration for log upload
198
compute_node_upload_batch_service_logs_options: Additional options
199
200
Returns:
201
UploadBatchServiceLogsResult: Upload results
202
"""
203
```
204
205
## Usage Examples
206
207
### Listing and Inspecting Compute Nodes
208
209
```python
210
# List all nodes in a pool
211
nodes = client.compute_node.list("my-pool")
212
for node in nodes:
213
print(f"Node {node.id}: {node.state} (IP: {node.ip_address})")
214
print(f" VM Size: {node.vm_size}")
215
print(f" Running tasks: {node.running_tasks_count}")
216
print(f" Total tasks run: {node.total_tasks_run}")
217
218
# Get detailed information about a specific node
219
node = client.compute_node.get("my-pool", "tvm-123456789")
220
print(f"Node state: {node.state}")
221
print(f"Node agent version: {node.node_agent_info.version}")
222
if node.recent_tasks:
223
print("Recent tasks:")
224
for task_info in node.recent_tasks:
225
print(f" {task_info.task_id}: {task_info.task_state}")
226
```
227
228
### Managing Users on Compute Nodes
229
230
```python
231
from azure.batch.models import ComputeNodeUser
232
233
# Add a user for remote access
234
user = ComputeNodeUser(
235
name="batchuser",
236
password="SecurePassword123!",
237
is_admin=False, # Non-admin user
238
expiry_time=datetime.datetime.utcnow() + datetime.timedelta(days=7)
239
)
240
241
client.compute_node.add_user("my-pool", "tvm-123456789", user)
242
243
# Update user password
244
from azure.batch.models import NodeUpdateUserParameter
245
update_params = NodeUpdateUserParameter(
246
password="NewSecurePassword456!",
247
expiry_time=datetime.datetime.utcnow() + datetime.timedelta(days=14)
248
)
249
250
client.compute_node.update_user("my-pool", "tvm-123456789", "batchuser", update_params)
251
252
# Delete user when no longer needed
253
client.compute_node.delete_user("my-pool", "tvm-123456789", "batchuser")
254
```
255
256
### Node Maintenance Operations
257
258
```python
259
from azure.batch.models import NodeRebootParameter, NodeReimageParameter
260
261
# Reboot a node (wait for running tasks to complete)
262
reboot_params = NodeRebootParameter(node_reboot_option="taskcompletion")
263
client.compute_node.reboot("my-pool", "tvm-123456789", reboot_params)
264
265
# Reboot immediately (terminate running tasks)
266
reboot_params = NodeRebootParameter(node_reboot_option="terminate")
267
client.compute_node.reboot("my-pool", "tvm-123456789", reboot_params)
268
269
# Reimage a node (reinstall OS, wait for tasks to complete)
270
reimage_params = NodeReimageParameter(node_reimage_option="taskcompletion")
271
client.compute_node.reimage("my-pool", "tvm-123456789", reimage_params)
272
273
# Reimage immediately
274
reimage_params = NodeReimageParameter(node_reimage_option="terminate")
275
client.compute_node.reimage("my-pool", "tvm-123456789", reimage_params)
276
```
277
278
### Controlling Task Scheduling
279
280
```python
281
from azure.batch.models import NodeDisableSchedulingParameter
282
283
# Disable scheduling on a node (complete running tasks)
284
disable_params = NodeDisableSchedulingParameter(
285
node_disable_scheduling_option="taskcompletion"
286
)
287
client.compute_node.disable_scheduling("my-pool", "tvm-123456789", disable_params)
288
289
# Check node state after disabling scheduling
290
node = client.compute_node.get("my-pool", "tvm-123456789")
291
print(f"Scheduling state: {node.scheduling_state}") # Should be "disabled"
292
293
# Re-enable scheduling
294
client.compute_node.enable_scheduling("my-pool", "tvm-123456789")
295
```
296
297
### Remote Access Setup
298
299
```python
300
# Get remote login settings (SSH for Linux, RDP for Windows)
301
login_settings = client.compute_node.get_remote_login_settings("my-pool", "tvm-123456789")
302
print(f"Remote login IP: {login_settings.remote_login_ip_address}")
303
print(f"Remote login port: {login_settings.remote_login_port}")
304
305
# For Windows nodes, get RDP file
306
rdp_file = client.compute_node.get_remote_desktop("my-pool", "tvm-123456789")
307
with open("node_rdp.rdp", "wb") as f:
308
for chunk in rdp_file:
309
f.write(chunk)
310
```
311
312
### Uploading Service Logs
313
314
```python
315
from azure.batch.models import UploadBatchServiceLogsConfiguration
316
317
# Upload batch service logs for debugging
318
log_config = UploadBatchServiceLogsConfiguration(
319
container_url="https://mystorageaccount.blob.core.windows.net/logs?sas_token",
320
start_time=datetime.datetime.utcnow() - datetime.timedelta(hours=24) # Last 24 hours
321
)
322
323
result = client.compute_node.upload_batch_service_logs("my-pool", "tvm-123456789", log_config)
324
print(f"Uploaded {result.number_of_files_uploaded} log files")
325
print(f"Virtual directory: {result.virtual_directory_name}")
326
```
327
328
## Types
329
330
### Compute Node Information Types
331
332
```python { .api }
333
class ComputeNode:
334
"""Compute node information and state."""
335
def __init__(self):
336
self.id: str
337
self.url: str
338
self.state: str # idle, running, starttaskfailed, etc.
339
self.scheduling_state: str # enabled, disabled
340
self.state_transition_time: datetime.datetime
341
self.last_boot_time: datetime.datetime
342
self.allocation_time: datetime.datetime
343
self.ip_address: str
344
self.affinity_id: str
345
self.vm_size: str
346
self.total_tasks_run: int
347
self.running_tasks_count: int
348
self.running_task_slots_count: int
349
self.total_tasks_succeeded: int
350
self.recent_tasks: List[TaskInformation]
351
self.start_task: StartTask
352
self.start_task_info: StartTaskInformation
353
self.certificate_references: List[CertificateReference]
354
self.errors: List[ComputeNodeError]
355
self.is_dedicated: bool
356
self.endpoint_configuration: ComputeNodeEndpointConfiguration
357
self.node_agent_info: NodeAgentInformation
358
self.virtual_machine_info: VirtualMachineInfo
359
360
class ComputeNodeUser:
361
"""User account for compute node."""
362
def __init__(self):
363
self.name: str
364
self.is_admin: bool
365
self.expiry_time: datetime.datetime
366
self.password: str
367
self.ssh_public_key: str
368
369
class ComputeNodeGetRemoteLoginSettingsResult:
370
"""Remote login settings for compute node."""
371
def __init__(self):
372
self.remote_login_ip_address: str
373
self.remote_login_port: int
374
375
class NodeAgentInformation:
376
"""Node agent information."""
377
def __init__(self):
378
self.version: str
379
self.last_update_time: datetime.datetime
380
381
class TaskInformation:
382
"""Information about a task that ran on the node."""
383
def __init__(self):
384
self.task_url: str
385
self.job_id: str
386
self.task_id: str
387
self.subtask_id: int
388
self.task_state: str
389
self.execution_info: TaskExecutionInformation
390
```
391
392
### Node Operation Parameter Types
393
394
```python { .api }
395
class NodeRebootParameter:
396
"""Parameters for rebooting a compute node."""
397
def __init__(self):
398
self.node_reboot_option: str # requeue, terminate, taskcompletion, retaineddata
399
400
class NodeReimageParameter:
401
"""Parameters for reimaging a compute node."""
402
def __init__(self):
403
self.node_reimage_option: str # requeue, terminate, taskcompletion, retaineddata
404
405
class NodeDisableSchedulingParameter:
406
"""Parameters for disabling scheduling on a compute node."""
407
def __init__(self):
408
self.node_disable_scheduling_option: str # requeue, terminate, taskcompletion
409
410
class NodeUpdateUserParameter:
411
"""Parameters for updating a user on a compute node."""
412
def __init__(self):
413
self.password: str
414
self.expiry_time: datetime.datetime
415
self.ssh_public_key: str
416
417
class UploadBatchServiceLogsConfiguration:
418
"""Configuration for uploading batch service logs."""
419
def __init__(self):
420
self.container_url: str
421
self.start_time: datetime.datetime
422
self.end_time: datetime.datetime
423
424
class UploadBatchServiceLogsResult:
425
"""Result of uploading batch service logs."""
426
def __init__(self):
427
self.virtual_directory_name: str
428
self.number_of_files_uploaded: int
429
```