0
# Pool Management
1
2
Creation and management of compute pools for batch workloads, including virtual machine configuration, scaling policies, network settings, and monitoring capabilities.
3
4
## Capabilities
5
6
### Pool Creation
7
8
Creates compute pools with specified virtual machine configurations, scaling policies, and network settings.
9
10
```python { .api }
11
def create(
12
resource_group_name: str,
13
account_name: str,
14
pool_name: str,
15
parameters: Pool,
16
if_match: str = None,
17
if_none_match: str = None,
18
**kwargs: Any
19
) -> LROPoller[Pool]:
20
"""
21
Creates a new pool inside the specified account.
22
23
Args:
24
resource_group_name (str): The name of the resource group
25
account_name (str): The name of the Batch account
26
pool_name (str): The pool name
27
parameters (Pool): Pool configuration parameters
28
if_match (str, optional): ETag value for conditional operations
29
if_none_match (str, optional): ETag value for conditional operations
30
31
Returns:
32
LROPoller[Pool]: Long-running operation poller for the created pool
33
"""
34
```
35
36
### Pool Retrieval
37
38
Retrieves detailed information about an existing pool including current state and node counts.
39
40
```python { .api }
41
def get(
42
resource_group_name: str,
43
account_name: str,
44
pool_name: str,
45
**kwargs: Any
46
) -> Pool:
47
"""
48
Gets information about the specified pool.
49
50
Args:
51
resource_group_name (str): The name of the resource group
52
account_name (str): The name of the Batch account
53
pool_name (str): The pool name
54
55
Returns:
56
Pool: The pool details
57
"""
58
```
59
60
### Pool Updates
61
62
Updates pool properties including scaling settings, application packages, and metadata.
63
64
```python { .api }
65
def update(
66
resource_group_name: str,
67
account_name: str,
68
pool_name: str,
69
parameters: Pool,
70
if_match: str = None,
71
**kwargs: Any
72
) -> Pool:
73
"""
74
Updates the properties of the specified pool.
75
76
Args:
77
resource_group_name (str): The name of the resource group
78
account_name (str): The name of the Batch account
79
pool_name (str): The pool name
80
parameters (Pool): Pool update parameters
81
if_match (str, optional): ETag value for conditional operations
82
83
Returns:
84
Pool: The updated pool
85
"""
86
```
87
88
### Pool Deletion
89
90
Deletes a pool and terminates all compute nodes.
91
92
```python { .api }
93
def delete(
94
resource_group_name: str,
95
account_name: str,
96
pool_name: str,
97
**kwargs: Any
98
) -> LROPoller[None]:
99
"""
100
Deletes the specified pool.
101
102
Args:
103
resource_group_name (str): The name of the resource group
104
account_name (str): The name of the Batch account
105
pool_name (str): The pool name
106
107
Returns:
108
LROPoller[None]: Long-running operation poller for the deletion
109
"""
110
```
111
112
### Pool Listing
113
114
Lists pools within a Batch account with optional filtering.
115
116
```python { .api }
117
def list_by_batch_account(
118
resource_group_name: str,
119
account_name: str,
120
maxresults: int = None,
121
select: str = None,
122
filter: str = None,
123
**kwargs: Any
124
) -> ItemPaged[Pool]:
125
"""
126
Lists all pools in the specified account.
127
128
Args:
129
resource_group_name (str): The name of the resource group
130
account_name (str): The name of the Batch account
131
maxresults (int, optional): Maximum number of results to return
132
select (str, optional): OData select clause
133
filter (str, optional): OData filter clause
134
135
Returns:
136
ItemPaged[Pool]: Paginated list of pools
137
"""
138
```
139
140
### Pool Scaling Operations
141
142
Stops any ongoing resize operation on a pool.
143
144
```python { .api }
145
def stop_resize(
146
resource_group_name: str,
147
account_name: str,
148
pool_name: str,
149
**kwargs: Any
150
) -> Pool:
151
"""
152
Stops an ongoing resize operation on the pool.
153
154
Args:
155
resource_group_name (str): The name of the resource group
156
account_name (str): The name of the Batch account
157
pool_name (str): The pool name
158
159
Returns:
160
Pool: The updated pool
161
"""
162
```
163
164
### Pool Disabling
165
166
Disables automatic scaling on a pool.
167
168
```python { .api }
169
def disable_auto_scale(
170
resource_group_name: str,
171
account_name: str,
172
pool_name: str,
173
**kwargs: Any
174
) -> Pool:
175
"""
176
Disables automatic scaling on the specified pool.
177
178
Args:
179
resource_group_name (str): The name of the resource group
180
account_name (str): The name of the Batch account
181
pool_name (str): The pool name
182
183
Returns:
184
Pool: The updated pool
185
"""
186
```
187
188
## Types
189
190
### Pool Configuration Types
191
192
```python { .api }
193
class Pool:
194
id: str
195
name: str
196
type: str
197
etag: str
198
identity: BatchPoolIdentity
199
display_name: str
200
last_modified: datetime
201
creation_time: datetime
202
provisioning_state: PoolProvisioningState
203
provisioning_state_transition_time: datetime
204
allocation_state: AllocationState
205
allocation_state_transition_time: datetime
206
vm_size: str
207
inter_node_communication: InterNodeCommunicationState
208
max_tasks_per_node: int
209
task_scheduling_policy: TaskSchedulingPolicy
210
deployment_configuration: DeploymentConfiguration
211
scale_settings: ScaleSettings
212
start_task: StartTask
213
certificates: list
214
application_packages: list
215
application_licenses: list
216
user_accounts: list
217
metadata: list
218
mount_configuration: list
219
target_node_communication_mode: NodeCommunicationMode
220
current_node_communication_mode: NodeCommunicationMode
221
network_configuration: NetworkConfiguration
222
current_dedicated_nodes: int
223
current_low_priority_nodes: int
224
target_dedicated_nodes: int
225
target_low_priority_nodes: int
226
resize_timeout: timedelta
227
resize_errors: list
228
upgrade_policy: UpgradePolicy
229
230
class DeploymentConfiguration:
231
virtual_machine_configuration: VirtualMachineConfiguration
232
233
class VirtualMachineConfiguration:
234
image_reference: ImageReference
235
node_agent_sku_id: str
236
windows_configuration: WindowsConfiguration
237
data_disks: list
238
license_type: str
239
container_configuration: ContainerConfiguration
240
disk_encryption_configuration: DiskEncryptionConfiguration
241
node_placement_configuration: NodePlacementConfiguration
242
extensions: list
243
os_disk: OSDisk
244
security_profile: SecurityProfile
245
246
class ScaleSettings:
247
fixed_scale: FixedScaleSettings
248
auto_scale: AutoScaleSettings
249
250
class NetworkConfiguration:
251
subnet_id: str
252
dynamic_v_net_assignment_scope: DynamicVNetAssignmentScope
253
endpoint_configuration: PoolEndpointConfiguration
254
public_ip_address_configuration: PublicIPAddressConfiguration
255
enable_accelerated_networking: bool
256
257
class BatchPoolIdentity:
258
type: PoolIdentityType
259
user_assigned_identities: dict
260
```
261
262
### Virtual Machine Configuration Types
263
264
```python { .api }
265
class ImageReference:
266
publisher: str
267
offer: str
268
sku: str
269
version: str
270
id: str
271
shared_image_gallery_image_id: str
272
273
class WindowsConfiguration:
274
enable_automatic_updates: bool
275
276
class ContainerConfiguration:
277
type: ContainerType
278
container_image_names: list
279
container_registries: list
280
281
class SecurityProfile:
282
uefi_settings: UefiSettings
283
encryption_at_host: bool
284
security_type: SecurityTypes
285
286
class StartTask:
287
command_line: str
288
container_settings: TaskContainerSettings
289
resource_files: list
290
environment_settings: list
291
user_identity: UserIdentity
292
max_task_retry_count: int
293
wait_for_success: bool
294
```
295
296
### Scaling Configuration Types
297
298
```python { .api }
299
class FixedScaleSettings:
300
target_dedicated_nodes: int
301
target_low_priority_nodes: int
302
resize_timeout: timedelta
303
node_deallocation_option: ComputeNodeDeallocationOption
304
305
class AutoScaleSettings:
306
formula: str
307
evaluation_interval: timedelta
308
309
class AutoScaleRun:
310
timestamp: datetime
311
results: str
312
error: AutoScaleRunError
313
```
314
315
## Usage Examples
316
317
### Creating a Virtual Machine Pool
318
319
```python
320
from azure.mgmt.batch.models import (
321
Pool, VirtualMachineConfiguration, ImageReference,
322
DeploymentConfiguration, FixedScaleSettings, ScaleSettings
323
)
324
325
# Configure VM image
326
image_ref = ImageReference(
327
publisher="Canonical",
328
offer="0001-com-ubuntu-server-focal",
329
sku="20_04-lts-gen2",
330
version="latest"
331
)
332
333
# Configure VM settings
334
vm_config = VirtualMachineConfiguration(
335
image_reference=image_ref,
336
node_agent_sku_id="batch.node.ubuntu 20.04"
337
)
338
339
deployment_config = DeploymentConfiguration(
340
virtual_machine_configuration=vm_config
341
)
342
343
# Configure scaling
344
fixed_scale = FixedScaleSettings(
345
target_dedicated_nodes=2,
346
target_low_priority_nodes=0
347
)
348
scale_settings = ScaleSettings(fixed_scale=fixed_scale)
349
350
# Create pool
351
pool = Pool(
352
vm_size="Standard_D2s_v3",
353
deployment_configuration=deployment_config,
354
scale_settings=scale_settings
355
)
356
357
operation = client.pool.create("my-resource-group", "my-batch-account", "my-pool", pool)
358
created_pool = operation.result()
359
print(f"Created pool: {created_pool.name}")
360
```
361
362
### Creating an Auto-Scaling Pool
363
364
```python
365
from azure.mgmt.batch.models import AutoScaleSettings
366
from datetime import timedelta
367
368
# Configure auto-scaling formula
369
auto_scale = AutoScaleSettings(
370
formula="""
371
startingNumberOfVMs = 1;
372
maxNumberofVMs = 25;
373
pendingTaskSamplePercent = $PendingTasks.GetSamplePercent(180 * TimeInterval_Second);
374
pendingTaskSamples = pendingTaskSamplePercent < 70 ? startingNumberOfVMs : avg($PendingTasks.GetSample(180 * TimeInterval_Second));
375
$TargetDedicatedNodes = min(maxNumberofVMs, pendingTaskSamples);
376
""",
377
evaluation_interval=timedelta(minutes=15)
378
)
379
380
scale_settings = ScaleSettings(auto_scale=auto_scale)
381
382
pool = Pool(
383
vm_size="Standard_D2s_v3",
384
deployment_configuration=deployment_config,
385
scale_settings=scale_settings
386
)
387
388
operation = client.pool.create("my-resource-group", "my-batch-account", "auto-pool", pool)
389
auto_pool = operation.result()
390
```
391
392
### Pool Monitoring
393
394
```python
395
# Get pool details and current state
396
pool = client.pool.get("my-resource-group", "my-batch-account", "my-pool")
397
398
print(f"Pool: {pool.name}")
399
print(f"VM Size: {pool.vm_size}")
400
print(f"Provisioning State: {pool.provisioning_state}")
401
print(f"Allocation State: {pool.allocation_state}")
402
print(f"Current Nodes: {pool.current_dedicated_nodes}")
403
print(f"Target Nodes: {pool.target_dedicated_nodes}")
404
405
if pool.resize_errors:
406
print("Resize Errors:")
407
for error in pool.resize_errors:
408
print(f" - {error.code}: {error.message}")
409
```