0
# Application Management
1
2
Deployment and version management for applications that run on Batch compute nodes, including application packages and version control.
3
4
## Core Imports
5
6
```python
7
from azure.mgmt.batch.operations import ApplicationOperations, ApplicationPackageOperations
8
from azure.mgmt.batch.models import Application, ApplicationPackage, ActivateApplicationPackageParameters
9
from azure.core.paging import ItemPaged
10
from typing import Union, Optional, IO, Any
11
```
12
13
## Capabilities
14
15
### Application Creation
16
17
Creates new applications within a Batch account for deployment to compute nodes.
18
19
```python { .api }
20
def create(
21
resource_group_name: str,
22
account_name: str,
23
application_name: str,
24
parameters: Application = None,
25
**kwargs: Any
26
) -> Application:
27
"""
28
Adds an application to the specified Batch account.
29
30
Args:
31
resource_group_name (str): The name of the resource group
32
account_name (str): The name of the Batch account
33
application_name (str): The name of the application
34
parameters (Application, optional): Application creation parameters
35
36
Returns:
37
Application: The created application
38
"""
39
```
40
41
### Application Retrieval
42
43
Retrieves detailed information about an existing application.
44
45
```python { .api }
46
def get(
47
resource_group_name: str,
48
account_name: str,
49
application_name: str,
50
**kwargs: Any
51
) -> Application:
52
"""
53
Gets information about the specified application.
54
55
Args:
56
resource_group_name (str): The name of the resource group
57
account_name (str): The name of the Batch account
58
application_name (str): The name of the application
59
60
Returns:
61
Application: The application details
62
"""
63
```
64
65
### Application Updates
66
67
Updates application properties including display name, default version, and update permissions.
68
69
```python { .api }
70
def update(
71
resource_group_name: str,
72
account_name: str,
73
application_name: str,
74
parameters: Application,
75
**kwargs: Any
76
) -> Application:
77
"""
78
Updates settings for the specified application.
79
80
Args:
81
resource_group_name (str): The name of the resource group
82
account_name (str): The name of the Batch account
83
application_name (str): The name of the application
84
parameters (Application): Application update parameters
85
86
Returns:
87
Application: The updated application
88
"""
89
```
90
91
### Application Deletion
92
93
Deletes an application and all its versions.
94
95
```python { .api }
96
def delete(
97
resource_group_name: str,
98
account_name: str,
99
application_name: str,
100
**kwargs: Any
101
) -> None:
102
"""
103
Deletes an application.
104
105
Args:
106
resource_group_name (str): The name of the resource group
107
account_name (str): The name of the Batch account
108
application_name (str): The name of the application
109
"""
110
```
111
112
### Application Listing
113
114
Lists all applications within a Batch account.
115
116
```python { .api }
117
def list(
118
resource_group_name: str,
119
account_name: str,
120
maxresults: int = None,
121
**kwargs: Any
122
) -> ItemPaged[Application]:
123
"""
124
Lists all applications in the specified account.
125
126
Args:
127
resource_group_name (str): The name of the resource group
128
account_name (str): The name of the Batch account
129
maxresults (int, optional): Maximum number of results to return
130
131
Returns:
132
ItemPaged[Application]: Paginated list of applications
133
"""
134
```
135
136
## Application Package Operations
137
138
Application packages contain the binary files deployed to compute nodes for task execution.
139
140
### Package Creation
141
142
Creates an application package record with a storage URL for uploading package contents.
143
144
```python { .api }
145
def create(
146
resource_group_name: str,
147
account_name: str,
148
application_name: str,
149
version_name: str,
150
parameters: Optional[Union[ApplicationPackage, IO[bytes]]] = None,
151
**kwargs: Any
152
) -> ApplicationPackage:
153
"""
154
Creates an application package record. The record contains a storageUrl where the package
155
should be uploaded to. Once uploaded, the ApplicationPackage needs to be activated.
156
157
Args:
158
resource_group_name (str): The name of the resource group
159
account_name (str): The name of the Batch account
160
application_name (str): The name of the application
161
version_name (str): The version of the application
162
parameters (ApplicationPackage | IO[bytes], optional): Package parameters
163
164
Returns:
165
ApplicationPackage: The created application package with storage URL
166
"""
167
```
168
169
### Package Activation
170
171
Activates an uploaded package to make it available for deployment to compute nodes.
172
173
```python { .api }
174
def activate(
175
resource_group_name: str,
176
account_name: str,
177
application_name: str,
178
version_name: str,
179
parameters: Union[ActivateApplicationPackageParameters, IO[bytes]],
180
**kwargs: Any
181
) -> ApplicationPackage:
182
"""
183
Activates the specified application package. This should be done after the
184
ApplicationPackage was created and uploaded. This needs to be done before an
185
ApplicationPackage can be used on Pools or Tasks.
186
187
Args:
188
resource_group_name (str): The name of the resource group
189
account_name (str): The name of the Batch account
190
application_name (str): The name of the application
191
version_name (str): The version of the application
192
parameters (ActivateApplicationPackageParameters | IO[bytes]): Activation parameters
193
194
Returns:
195
ApplicationPackage: The activated application package
196
"""
197
```
198
199
### Package Retrieval
200
201
Gets information about a specific application package version.
202
203
```python { .api }
204
def get(
205
resource_group_name: str,
206
account_name: str,
207
application_name: str,
208
version_name: str,
209
**kwargs: Any
210
) -> ApplicationPackage:
211
"""
212
Gets information about the specified application package.
213
214
Args:
215
resource_group_name (str): The name of the resource group
216
account_name (str): The name of the Batch account
217
application_name (str): The name of the application
218
version_name (str): The version of the application
219
220
Returns:
221
ApplicationPackage: The application package details
222
"""
223
```
224
225
### Package Deletion
226
227
Deletes an application package record and its associated binary file.
228
229
```python { .api }
230
def delete(
231
resource_group_name: str,
232
account_name: str,
233
application_name: str,
234
version_name: str,
235
**kwargs: Any
236
) -> None:
237
"""
238
Deletes an application package record and its associated binary file.
239
240
Args:
241
resource_group_name (str): The name of the resource group
242
account_name (str): The name of the Batch account
243
application_name (str): The name of the application
244
version_name (str): The version of the application
245
"""
246
```
247
248
### Package Listing
249
250
Lists all package versions for an application.
251
252
```python { .api }
253
def list(
254
resource_group_name: str,
255
account_name: str,
256
application_name: str,
257
maxresults: Optional[int] = None,
258
**kwargs: Any
259
) -> ItemPaged[ApplicationPackage]:
260
"""
261
Lists all of the application packages in the specified application.
262
263
Args:
264
resource_group_name (str): The name of the resource group
265
account_name (str): The name of the Batch account
266
application_name (str): The name of the application
267
maxresults (int, optional): Maximum number of items to return in the response
268
269
Returns:
270
ItemPaged[ApplicationPackage]: An iterator of ApplicationPackage objects
271
"""
272
```
273
274
## Types
275
276
### Application Types
277
278
```python { .api }
279
class Application:
280
id: str
281
name: str
282
type: str
283
etag: str
284
display_name: str
285
allow_updates: bool
286
default_version: str
287
288
class ApplicationPackage:
289
id: str
290
name: str
291
type: str
292
etag: str
293
state: PackageState
294
format: str
295
storage_url: str
296
storage_url_expiry: datetime
297
last_activation_time: datetime
298
299
class ActivateApplicationPackageParameters:
300
format: str
301
302
class ApplicationPackageReference:
303
id: str
304
version: str
305
```
306
307
## Usage Examples
308
309
### Creating and Managing Applications
310
311
```python
312
# Create a new application
313
app_params = {
314
"display_name": "My Batch Application",
315
"allow_updates": True
316
}
317
318
application = client.application.create(
319
"my-resource-group",
320
"my-batch-account",
321
"my-app",
322
app_params
323
)
324
print(f"Created application: {application.display_name}")
325
326
# Update application settings
327
update_params = {
328
"display_name": "Updated Application Name",
329
"allow_updates": False,
330
"default_version": "1.0"
331
}
332
333
updated_app = client.application.update(
334
"my-resource-group",
335
"my-batch-account",
336
"my-app",
337
update_params
338
)
339
```
340
341
### Managing Application Packages
342
343
```python
344
from azure.mgmt.batch.models import ActivateApplicationPackageParameters
345
346
# Create a new application package version
347
package = client.application_package.create(
348
"my-resource-group",
349
"my-batch-account",
350
"my-app",
351
"1.0"
352
)
353
print(f"Package URL for upload: {package.storage_url}")
354
355
# Upload your application files to the storage_url
356
# (This would be done using Azure Storage SDK or REST API)
357
358
# Activate the package after uploading files
359
activation_params = ActivateApplicationPackageParameters(format="zip")
360
activated_package = client.application_package.activate(
361
"my-resource-group",
362
"my-batch-account",
363
"my-app",
364
"1.0",
365
activation_params
366
)
367
print(f"Package state: {activated_package.state}")
368
```
369
370
### Using Applications in Pool Configuration
371
372
```python
373
from azure.mgmt.batch.models import ApplicationPackageReference
374
375
# Reference application packages in pool configuration
376
app_packages = [
377
ApplicationPackageReference(id="my-app", version="1.0"),
378
ApplicationPackageReference(id="my-other-app", version="2.1")
379
]
380
381
# Use in pool creation (this would be part of a Pool object)
382
pool_config = {
383
"application_packages": app_packages,
384
# ... other pool configuration
385
}
386
```
387
388
### Listing and Monitoring Applications
389
390
```python
391
# List all applications
392
applications = client.application.list("my-resource-group", "my-batch-account")
393
for app in applications:
394
print(f"Application: {app.name}, Default Version: {app.default_version}")
395
396
# List packages for each application
397
packages = client.application_package.list(
398
"my-resource-group",
399
"my-batch-account",
400
app.name
401
)
402
for package in packages:
403
print(f" Package: {package.name}, State: {package.state}")
404
```