0
# Application Operations
1
2
Application package management capabilities for managing and deploying application packages to batch pools and tasks. Application packages provide a convenient way to deploy and manage application binaries and dependencies on compute nodes.
3
4
## Capabilities
5
6
### Application Package Listing
7
8
Retrieve information about available application packages in the batch account.
9
10
```python { .api }
11
def list(application_list_options=None, custom_headers=None, raw=False, **operation_config):
12
"""
13
List all applications available in the specified account.
14
15
Returns only applications and versions that are available for use on
16
compute nodes; that is, that can be used in an application package reference.
17
18
Args:
19
application_list_options: Additional options for listing applications
20
custom_headers: Custom headers to include in request
21
raw: Return raw response if True
22
23
Returns:
24
ItemPaged[ApplicationSummary]: Paginated list of applications
25
"""
26
```
27
28
### Application Package Information
29
30
Get detailed information about specific application packages.
31
32
```python { .api }
33
def get(application_id, application_get_options=None, custom_headers=None, raw=False, **operation_config):
34
"""
35
Get information about the specified application.
36
37
Args:
38
application_id: ID of the application to retrieve
39
application_get_options: Additional options for the operation
40
custom_headers: Custom headers to include in request
41
raw: Return raw response if True
42
43
Returns:
44
ApplicationSummary: Application information including available versions
45
"""
46
```
47
48
## Usage Examples
49
50
### Listing Available Applications
51
52
```python
53
# List all available applications
54
applications = client.application.list()
55
for app in applications:
56
print(f"Application: {app.id}")
57
print(f" Display Name: {app.display_name}")
58
print(f" Versions: {app.versions}")
59
print(f" Default Version: {app.default_version}")
60
61
# List applications with filtering
62
from azure.batch.models import ApplicationListOptions
63
list_options = ApplicationListOptions(
64
filter="startswith(id, 'myapp')",
65
max_results=10
66
)
67
filtered_apps = client.application.list(list_options)
68
```
69
70
### Getting Application Details
71
72
```python
73
# Get details for a specific application
74
app_details = client.application.get("myapp")
75
print(f"Application ID: {app_details.id}")
76
print(f"Display Name: {app_details.display_name}")
77
print(f"Default Version: {app_details.default_version}")
78
print("Available Versions:")
79
for version in app_details.versions:
80
print(f" - {version}")
81
82
# Check if specific application exists
83
try:
84
app = client.application.get("nonexistent-app")
85
print("Application exists")
86
except Exception as e:
87
print(f"Application not found: {e}")
88
```
89
90
### Using Applications in Pool Configuration
91
92
```python
93
from azure.batch.models import (
94
PoolSpecification, ApplicationPackageReference,
95
VirtualMachineConfiguration, ImageReference
96
)
97
98
# Create pool with application packages
99
app_references = [
100
ApplicationPackageReference(
101
application_id="myapp",
102
version="1.0" # Use specific version
103
),
104
ApplicationPackageReference(
105
application_id="mylib"
106
# No version specified - uses default version
107
)
108
]
109
110
pool_spec = PoolSpecification(
111
id="app-pool",
112
vm_size="Standard_D2s_v3",
113
virtual_machine_configuration=VirtualMachineConfiguration(
114
image_reference=ImageReference(
115
publisher="Canonical",
116
offer="UbuntuServer",
117
sku="18.04-LTS"
118
),
119
node_agent_sku_id="batch.node.ubuntu 18.04"
120
),
121
target_dedicated_nodes=2,
122
application_packages=app_references
123
)
124
125
client.pool.add(pool_spec)
126
```
127
128
### Using Applications in Task Configuration
129
130
```python
131
from azure.batch.models import TaskSpecification, ApplicationPackageReference
132
133
# Create task that uses application packages
134
task_app_refs = [
135
ApplicationPackageReference(
136
application_id="processing-tool",
137
version="2.1"
138
)
139
]
140
141
task_spec = TaskSpecification(
142
id="processing-task",
143
command_line="$AZ_BATCH_APP_PACKAGE_processing-tool#2.1/bin/process input.dat",
144
application_package_references=task_app_refs
145
)
146
147
client.task.add("my-job", task_spec)
148
```
149
150
## Types
151
152
### Application Information Types
153
154
```python { .api }
155
class ApplicationSummary:
156
"""Application package summary information."""
157
def __init__(self):
158
self.id: str
159
self.display_name: str
160
self.versions: List[str]
161
self.default_version: str
162
163
class ApplicationPackageReference:
164
"""Reference to an application package."""
165
def __init__(self):
166
self.application_id: str
167
self.version: str # Optional - uses default if not specified
168
```
169
170
### Application Operation Option Types
171
172
```python { .api }
173
class ApplicationListOptions:
174
"""Options for listing applications."""
175
def __init__(self):
176
self.filter: str
177
self.select: str
178
self.max_results: int
179
self.timeout: int
180
181
class ApplicationGetOptions:
182
"""Options for getting application information."""
183
def __init__(self):
184
self.select: str
185
self.timeout: int
186
```
187
188
## Notes
189
190
- Application packages must be uploaded and configured through the Azure portal or ARM templates before they can be used
191
- Application packages are automatically extracted to the `$AZ_BATCH_APP_PACKAGE_<applicationId>#<version>` directory on compute nodes
192
- If no version is specified in ApplicationPackageReference, the default version is used
193
- Application packages are available to all tasks running on nodes where they are deployed
194
- Application packages provide an efficient way to deploy large applications without including them in resource files