or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

compute-services.mdindex.mdmessaging-integration.mdmonitoring-analytics.mdplatform-services.mdresource-management.mdsecurity-identity.md

compute-services.mddocs/

0

# Compute Services

1

2

Azure compute services provide batch processing, container management, and virtual machine management capabilities. This includes the Azure Batch service for large-scale parallel workloads and compute resource management for provisioning and configuring compute infrastructure.

3

4

## Capabilities

5

6

### Azure Batch Service

7

8

Enables large-scale parallel and high-performance computing (HPC) applications to run efficiently in the cloud. Manages compute pools, jobs, and tasks for batch processing workloads.

9

10

```python { .api }

11

class BatchServiceClient:

12

"""

13

Client for Azure Batch service operations.

14

15

Parameters:

16

- credentials: Authentication credentials (SharedKeyCredentials)

17

- base_url: str, Batch service endpoint URL (optional, defaults to 'https://batch.core.windows.net')

18

"""

19

def __init__(self, credentials, base_url=None, **kwargs): ...

20

21

@property

22

def pool(self): ... # Pool operations

23

24

@property

25

def job(self): ... # Job operations

26

27

@property

28

def task(self): ... # Task operations

29

30

@property

31

def compute_node(self): ... # Compute node operations

32

33

@property

34

def file(self): ... # File operations

35

```

36

37

#### Pool Operations

38

39

Manage compute pools for batch processing.

40

41

```python { .api }

42

class PoolOperations:

43

def add(self, pool, **kwargs):

44

"""Add a pool to the specified account."""

45

46

def delete(self, pool_id, **kwargs):

47

"""Delete a pool from the specified account."""

48

49

def get(self, pool_id, **kwargs):

50

"""Get information about the specified pool."""

51

52

def list(self, **kwargs):

53

"""List all pools in the specified account."""

54

55

def update_properties(self, pool_id, pool_update_parameter, **kwargs):

56

"""Update properties of the specified pool."""

57

58

def enable_auto_scale(self, pool_id, auto_scale_formula, **kwargs):

59

"""Enable automatic scaling on the specified pool."""

60

61

def disable_auto_scale(self, pool_id, **kwargs):

62

"""Disable automatic scaling on the specified pool."""

63

64

def evaluate_auto_scale(self, pool_id, auto_scale_formula, **kwargs):

65

"""Get the result of evaluating an automatic scaling formula."""

66

67

def resize(self, pool_id, pool_resize_parameter, **kwargs):

68

"""Change the number of compute nodes in the specified pool."""

69

70

def stop_resize(self, pool_id, **kwargs):

71

"""Stop an ongoing resize operation on the specified pool."""

72

```

73

74

#### Job Operations

75

76

Manage batch jobs and job scheduling.

77

78

```python { .api }

79

class JobOperations:

80

def add(self, job, **kwargs):

81

"""Add a job to the specified account."""

82

83

def delete(self, job_id, **kwargs):

84

"""Delete a job."""

85

86

def get(self, job_id, **kwargs):

87

"""Get information about the specified job."""

88

89

def list(self, **kwargs):

90

"""List all jobs in the specified account."""

91

92

def update(self, job_id, job_update_parameter, **kwargs):

93

"""Update properties of the specified job."""

94

95

def disable(self, job_id, disable_job_option, **kwargs):

96

"""Disable the specified job."""

97

98

def enable(self, job_id, **kwargs):

99

"""Enable the specified job."""

100

101

def terminate(self, job_id, **kwargs):

102

"""Terminate the specified job."""

103

```

104

105

#### Task Operations

106

107

Manage individual tasks within batch jobs.

108

109

```python { .api }

110

class TaskOperations:

111

def add(self, job_id, task, **kwargs):

112

"""Add a task to the specified job."""

113

114

def add_collection(self, job_id, value, **kwargs):

115

"""Add a collection of tasks to the specified job."""

116

117

def delete(self, job_id, task_id, **kwargs):

118

"""Delete a task from the specified job."""

119

120

def get(self, job_id, task_id, **kwargs):

121

"""Get information about the specified task."""

122

123

def list(self, job_id, **kwargs):

124

"""List all tasks associated with the specified job."""

125

126

def update(self, job_id, task_id, task_update_parameter, **kwargs):

127

"""Update properties of the specified task."""

128

129

def terminate(self, job_id, task_id, **kwargs):

130

"""Terminate the specified task."""

131

132

def reactivate(self, job_id, task_id, **kwargs):

133

"""Reactivate a task."""

134

```

135

136

### Batch Authentication

137

138

Provides authentication for Azure Batch services.

139

140

```python { .api }

141

class SharedKeyCredentials:

142

"""

143

Shared key credentials for Azure Batch authentication.

144

145

Parameters:

146

- account_name: str, Batch account name

147

- account_key: str, Batch account access key

148

"""

149

def __init__(self, account_name: str, account_key: str): ...

150

151

def signed_session(self, session=None):

152

"""Create a signed session for requests."""

153

```

154

155

### Compute Management

156

157

Manages Azure compute resources including virtual machines, availability sets, and compute-related infrastructure.

158

159

```python { .api }

160

class ComputeManagementClient:

161

"""

162

Client for Azure Compute Management operations.

163

164

Parameters:

165

- credentials: Authentication credentials (ServicePrincipalCredentials)

166

- subscription_id: str, Azure subscription ID

167

"""

168

def __init__(self, credentials, subscription_id, **kwargs): ...

169

170

@property

171

def virtual_machines(self): ... # VM operations

172

173

@property

174

def virtual_machine_sizes(self): ... # VM size operations

175

176

@property

177

def availability_sets(self): ... # Availability set operations

178

179

@property

180

def virtual_machine_scale_sets(self): ... # Scale set operations

181

182

@property

183

def virtual_machine_images(self): ... # VM image operations

184

185

@property

186

def usage(self): ... # Usage operations

187

188

@property

189

def disks(self): ... # Disk operations

190

191

@property

192

def snapshots(self): ... # Snapshot operations

193

```

194

195

## Key Models

196

197

### Pool Specification

198

199

```python { .api }

200

class PoolSpecification:

201

"""Specification for creating a batch pool."""

202

def __init__(self, id: str, vm_size: str, **kwargs): ...

203

204

id: str # Pool identifier

205

display_name: str # Display name

206

vm_size: str # Virtual machine size

207

cloud_service_configuration: object # Cloud service config

208

virtual_machine_configuration: object # VM config

209

target_dedicated_nodes: int # Target dedicated node count

210

target_low_priority_nodes: int # Target low priority node count

211

enable_auto_scale: bool # Auto scaling enabled

212

auto_scale_formula: str # Auto scaling formula

213

start_task: object # Start task specification

214

application_packages: list # Application packages

215

metadata: list # Pool metadata

216

```

217

218

### Job Specification

219

220

```python { .api }

221

class JobSpecification:

222

"""Specification for creating a batch job."""

223

def __init__(self, pool_info, **kwargs): ...

224

225

display_name: str # Display name

226

priority: int # Job priority

227

constraints: object # Job constraints

228

job_manager_task: object # Job manager task

229

job_preparation_task: object # Job preparation task

230

job_release_task: object # Job release task

231

pool_info: object # Pool information

232

common_environment_settings: list # Environment settings

233

metadata: list # Job metadata

234

```

235

236

### Task Specification

237

238

```python { .api }

239

class TaskAddParameter:

240

"""Parameters for adding a task to a job."""

241

def __init__(self, id: str, command_line: str, **kwargs): ...

242

243

id: str # Task identifier

244

display_name: str # Display name

245

command_line: str # Command line to execute

246

container_settings: object # Container settings

247

resource_files: list # Resource files

248

output_files: list # Output files

249

environment_settings: list # Environment settings

250

constraints: object # Task constraints

251

user_identity: object # User identity

252

depends_on: object # Task dependencies

253

application_package_references: list # Application packages

254

authentication_token_settings: object # Auth token settings

255

```

256

257

## Usage Examples

258

259

### Creating and Managing a Batch Pool

260

261

```python

262

from azure.batch import BatchServiceClient

263

from azure.batch.batch_auth import SharedKeyCredentials

264

from azure.batch.models import (

265

PoolSpecification,

266

VirtualMachineConfiguration,

267

ImageReference,

268

NodeAgentSku

269

)

270

271

# Set up authentication

272

credentials = SharedKeyCredentials(account_name, account_key)

273

batch_client = BatchServiceClient(credentials, base_url=batch_url)

274

275

# Create a pool specification

276

vm_config = VirtualMachineConfiguration(

277

image_reference=ImageReference(

278

publisher="Canonical",

279

offer="UbuntuServer",

280

sku="18.04-LTS"

281

),

282

node_agent_sku_id="batch.node.ubuntu 18.04"

283

)

284

285

pool_spec = PoolSpecification(

286

id="mypool",

287

vm_size="Standard_A1_v2",

288

target_dedicated_nodes=2,

289

virtual_machine_configuration=vm_config

290

)

291

292

# Create the pool

293

batch_client.pool.add(pool_spec)

294

295

# List pools

296

pools = batch_client.pool.list()

297

for pool in pools:

298

print(f"Pool: {pool.id}, State: {pool.state}")

299

```

300

301

### Submitting and Managing Batch Jobs

302

303

```python

304

from azure.batch.models import (

305

JobSpecification,

306

PoolInformation,

307

TaskAddParameter

308

)

309

310

# Create job specification

311

job_spec = JobSpecification(

312

pool_info=PoolInformation(pool_id="mypool")

313

)

314

315

# Add job

316

batch_client.job.add(job_spec, job_id="myjob")

317

318

# Add tasks to the job

319

tasks = []

320

for i in range(5):

321

task = TaskAddParameter(

322

id=f"task{i}",

323

command_line=f"echo 'Hello from task {i}'"

324

)

325

tasks.append(task)

326

327

batch_client.task.add_collection("myjob", tasks)

328

329

# Monitor task completion

330

tasks = batch_client.task.list("myjob")

331

for task in tasks:

332

print(f"Task {task.id}: {task.state}")

333

```