or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

cloud-services.mddisks-storage.mdimages-galleries.mdindex.mdinfrastructure.mdscale-sets.mdvirtual-machines.md

images-galleries.mddocs/

0

# Image and Gallery Management

1

2

Management of custom VM images, shared image galleries, and image versions for standardized deployments across organizations. This includes creating custom VM images, managing shared image galleries for enterprise-wide image distribution, and version control for application and OS images.

3

4

## Capabilities

5

6

### Custom Image Management

7

8

Operations for managing custom VM images created from generalized VMs or disks.

9

10

```python { .api }

11

class ImagesOperations:

12

def begin_create_or_update(

13

resource_group_name: str,

14

image_name: str,

15

parameters: Image

16

) -> LROPoller[Image]:

17

"""

18

Create or update a custom VM image.

19

20

Args:

21

resource_group_name: Name of the resource group

22

image_name: Name of the image

23

parameters: Image configuration including source VM or disk

24

25

Returns:

26

Long-running operation poller for Image

27

"""

28

29

def begin_delete(resource_group_name: str, image_name: str) -> LROPoller[None]:

30

"""

31

Delete a custom VM image.

32

33

Args:

34

resource_group_name: Name of the resource group

35

image_name: Name of the image

36

37

Returns:

38

Long-running operation poller

39

"""

40

41

def get(resource_group_name: str, image_name: str) -> Image:

42

"""

43

Get custom VM image details.

44

45

Args:

46

resource_group_name: Name of the resource group

47

image_name: Name of the image

48

49

Returns:

50

Image details

51

"""

52

53

def list() -> Iterable[Image]:

54

"""

55

List all custom images in the subscription.

56

57

Returns:

58

Iterable of all custom images

59

"""

60

61

def list_by_resource_group(resource_group_name: str) -> Iterable[Image]:

62

"""

63

List custom images in a resource group.

64

65

Args:

66

resource_group_name: Name of the resource group

67

68

Returns:

69

Iterable of custom images in the resource group

70

"""

71

```

72

73

### Shared Image Gallery Management

74

75

Operations for managing shared image galleries for enterprise image distribution.

76

77

```python { .api }

78

class GalleriesOperations:

79

def begin_create_or_update(

80

resource_group_name: str,

81

gallery_name: str,

82

gallery: Gallery

83

) -> LROPoller[Gallery]:

84

"""

85

Create or update a shared image gallery.

86

87

Args:

88

resource_group_name: Name of the resource group

89

gallery_name: Name of the gallery

90

gallery: Gallery configuration

91

92

Returns:

93

Long-running operation poller for Gallery

94

"""

95

96

def begin_delete(resource_group_name: str, gallery_name: str) -> LROPoller[None]:

97

"""

98

Delete a shared image gallery.

99

100

Args:

101

resource_group_name: Name of the resource group

102

gallery_name: Name of the gallery

103

104

Returns:

105

Long-running operation poller

106

"""

107

108

def get(resource_group_name: str, gallery_name: str) -> Gallery:

109

"""

110

Get shared image gallery details.

111

112

Args:

113

resource_group_name: Name of the resource group

114

gallery_name: Name of the gallery

115

116

Returns:

117

Gallery details

118

"""

119

120

def list() -> Iterable[Gallery]:

121

"""

122

List all shared image galleries in the subscription.

123

124

Returns:

125

Iterable of all galleries

126

"""

127

128

def list_by_resource_group(resource_group_name: str) -> Iterable[Gallery]:

129

"""

130

List shared image galleries in a resource group.

131

132

Args:

133

resource_group_name: Name of the resource group

134

135

Returns:

136

Iterable of galleries in the resource group

137

"""

138

```

139

140

### Gallery Image Definitions

141

142

Operations for managing image definitions within galleries.

143

144

```python { .api }

145

class GalleryImagesOperations:

146

def begin_create_or_update(

147

resource_group_name: str,

148

gallery_name: str,

149

gallery_image_name: str,

150

gallery_image: GalleryImage

151

) -> LROPoller[GalleryImage]:

152

"""

153

Create or update a gallery image definition.

154

155

Args:

156

resource_group_name: Name of the resource group

157

gallery_name: Name of the gallery

158

gallery_image_name: Name of the image definition

159

gallery_image: Image definition configuration

160

161

Returns:

162

Long-running operation poller for GalleryImage

163

"""

164

165

def begin_delete(

166

resource_group_name: str,

167

gallery_name: str,

168

gallery_image_name: str

169

) -> LROPoller[None]:

170

"""

171

Delete a gallery image definition.

172

173

Args:

174

resource_group_name: Name of the resource group

175

gallery_name: Name of the gallery

176

gallery_image_name: Name of the image definition

177

178

Returns:

179

Long-running operation poller

180

"""

181

182

def get(

183

resource_group_name: str,

184

gallery_name: str,

185

gallery_image_name: str

186

) -> GalleryImage:

187

"""

188

Get gallery image definition details.

189

190

Args:

191

resource_group_name: Name of the resource group

192

gallery_name: Name of the gallery

193

gallery_image_name: Name of the image definition

194

195

Returns:

196

Gallery image definition details

197

"""

198

199

def list_by_gallery(

200

resource_group_name: str,

201

gallery_name: str

202

) -> Iterable[GalleryImage]:

203

"""

204

List image definitions in a gallery.

205

206

Args:

207

resource_group_name: Name of the resource group

208

gallery_name: Name of the gallery

209

210

Returns:

211

Iterable of image definitions in the gallery

212

"""

213

```

214

215

### Gallery Image Versions

216

217

Operations for managing versions of gallery images.

218

219

```python { .api }

220

class GalleryImageVersionsOperations:

221

def begin_create_or_update(

222

resource_group_name: str,

223

gallery_name: str,

224

gallery_image_name: str,

225

gallery_image_version_name: str,

226

gallery_image_version: GalleryImageVersion

227

) -> LROPoller[GalleryImageVersion]:

228

"""

229

Create or update a gallery image version.

230

231

Args:

232

resource_group_name: Name of the resource group

233

gallery_name: Name of the gallery

234

gallery_image_name: Name of the image definition

235

gallery_image_version_name: Version name (e.g., '1.0.0')

236

gallery_image_version: Image version configuration

237

238

Returns:

239

Long-running operation poller for GalleryImageVersion

240

"""

241

242

def begin_delete(

243

resource_group_name: str,

244

gallery_name: str,

245

gallery_image_name: str,

246

gallery_image_version_name: str

247

) -> LROPoller[None]:

248

"""

249

Delete a gallery image version.

250

251

Args:

252

resource_group_name: Name of the resource group

253

gallery_name: Name of the gallery

254

gallery_image_name: Name of the image definition

255

gallery_image_version_name: Version name

256

257

Returns:

258

Long-running operation poller

259

"""

260

261

def get(

262

resource_group_name: str,

263

gallery_name: str,

264

gallery_image_name: str,

265

gallery_image_version_name: str

266

) -> GalleryImageVersion:

267

"""

268

Get gallery image version details.

269

270

Args:

271

resource_group_name: Name of the resource group

272

gallery_name: Name of the gallery

273

gallery_image_name: Name of the image definition

274

gallery_image_version_name: Version name

275

276

Returns:

277

Gallery image version details

278

"""

279

280

def list_by_gallery_image(

281

resource_group_name: str,

282

gallery_name: str,

283

gallery_image_name: str

284

) -> Iterable[GalleryImageVersion]:

285

"""

286

List versions of a gallery image.

287

288

Args:

289

resource_group_name: Name of the resource group

290

gallery_name: Name of the gallery

291

gallery_image_name: Name of the image definition

292

293

Returns:

294

Iterable of image versions

295

"""

296

```

297

298

### Gallery Applications

299

300

Operations for managing application packages in galleries.

301

302

```python { .api }

303

class GalleryApplicationsOperations:

304

def begin_create_or_update(

305

resource_group_name: str,

306

gallery_name: str,

307

gallery_application_name: str,

308

gallery_application: GalleryApplication

309

) -> LROPoller[GalleryApplication]:

310

"""

311

Create or update a gallery application.

312

313

Args:

314

resource_group_name: Name of the resource group

315

gallery_name: Name of the gallery

316

gallery_application_name: Name of the application

317

gallery_application: Application configuration

318

319

Returns:

320

Long-running operation poller for GalleryApplication

321

"""

322

323

def begin_delete(

324

resource_group_name: str,

325

gallery_name: str,

326

gallery_application_name: str

327

) -> LROPoller[None]:

328

"""

329

Delete a gallery application.

330

331

Args:

332

resource_group_name: Name of the resource group

333

gallery_name: Name of the gallery

334

gallery_application_name: Name of the application

335

336

Returns:

337

Long-running operation poller

338

"""

339

340

def get(

341

resource_group_name: str,

342

gallery_name: str,

343

gallery_application_name: str

344

) -> GalleryApplication:

345

"""

346

Get gallery application details.

347

348

Args:

349

resource_group_name: Name of the resource group

350

gallery_name: Name of the gallery

351

gallery_application_name: Name of the application

352

353

Returns:

354

Gallery application details

355

"""

356

```

357

358

## Data Types

359

360

```python { .api }

361

class Image:

362

"""Describes an Image."""

363

id: Optional[str]

364

name: Optional[str]

365

type: Optional[str]

366

location: str

367

tags: Optional[Dict[str, str]]

368

extended_location: Optional[ExtendedLocation]

369

source_virtual_machine: Optional[SubResource]

370

storage_profile: Optional[ImageStorageProfile]

371

provisioning_state: Optional[str]

372

hyper_v_generation: Optional[HyperVGenerationTypes]

373

374

class Gallery:

375

"""Specifies information about the Shared Image Gallery."""

376

id: Optional[str]

377

name: Optional[str]

378

type: Optional[str]

379

location: str

380

tags: Optional[Dict[str, str]]

381

description: Optional[str]

382

identifier: Optional[GalleryIdentifier]

383

provisioning_state: Optional[GalleryProvisioningState]

384

sharing_profile: Optional[SharingProfile]

385

soft_delete_policy: Optional[SoftDeletePolicy]

386

sharing_status: Optional[SharingStatus]

387

388

class GalleryImage:

389

"""Specifies information about the gallery image definition."""

390

id: Optional[str]

391

name: Optional[str]

392

type: Optional[str]

393

location: str

394

tags: Optional[Dict[str, str]]

395

description: Optional[str]

396

eula: Optional[str]

397

privacy_statement_uri: Optional[str]

398

release_note_uri: Optional[str]

399

os_type: OperatingSystemTypes

400

os_state: OperatingSystemStateTypes

401

hyper_v_generation: Optional[HyperVGeneration]

402

end_of_life_date: Optional[datetime]

403

identifier: GalleryImageIdentifier

404

recommended: Optional[RecommendedMachineConfiguration]

405

disallowed: Optional[Disallowed]

406

purchase_plan: Optional[ImagePurchasePlan]

407

provisioning_state: Optional[GalleryProvisioningState]

408

features: Optional[List[GalleryImageFeature]]

409

architecture: Optional[Architecture]

410

411

class GalleryImageVersion:

412

"""Specifies information about the gallery image version."""

413

id: Optional[str]

414

name: Optional[str]

415

type: Optional[str]

416

location: str

417

tags: Optional[Dict[str, str]]

418

publishing_profile: Optional[GalleryImageVersionPublishingProfile]

419

provisioning_state: Optional[GalleryImageVersionPropertiesProvisioningState]

420

storage_profile: GalleryImageVersionStorageProfile

421

safety_profile: Optional[GalleryImageVersionSafetyProfile]

422

replication_status: Optional[ReplicationStatus]

423

security_profile: Optional[ImageVersionSecurityProfile]

424

425

class GalleryApplication:

426

"""Specifies information about the gallery Application Definition."""

427

id: Optional[str]

428

name: Optional[str]

429

type: Optional[str]

430

location: str

431

tags: Optional[Dict[str, str]]

432

description: Optional[str]

433

eula: Optional[str]

434

privacy_statement_uri: Optional[str]

435

release_note_uri: Optional[str]

436

end_of_life_date: Optional[datetime]

437

supported_os_type: OperatingSystemTypes

438

custom_actions: Optional[List[GalleryApplicationCustomAction]]

439

provisioning_state: Optional[GalleryApplicationPropertiesProvisioningState]

440

441

class GalleryImageIdentifier:

442

"""This is the gallery image definition identifier."""

443

publisher: str

444

offer: str

445

sku: str

446

447

class ImageStorageProfile:

448

"""Describes a storage profile."""

449

os_disk: Optional[ImageOSDisk]

450

data_disks: Optional[List[ImageDataDisk]]

451

zone_resilient: Optional[bool]

452

```

453

454

## Usage Examples

455

456

### Create Custom Image from VM

457

458

```python

459

from azure.identity import DefaultAzureCredential

460

from azure.mgmt.compute import ComputeManagementClient

461

462

credential = DefaultAzureCredential()

463

compute_client = ComputeManagementClient(credential, "subscription-id")

464

465

# Create custom image from a generalized VM

466

image_parameters = {

467

'location': 'East US',

468

'source_virtual_machine': {

469

'id': '/subscriptions/.../virtualMachines/myGeneralizedVM'

470

},

471

'tags': {

472

'created_by': 'automation',

473

'base_os': 'ubuntu-20.04'

474

}

475

}

476

477

operation = compute_client.images.begin_create_or_update(

478

'myResourceGroup',

479

'myCustomImage',

480

image_parameters

481

)

482

custom_image = operation.result()

483

print(f"Custom image created: {custom_image.name}")

484

```

485

486

### Setup Shared Image Gallery

487

488

```python

489

# Create shared image gallery

490

gallery_parameters = {

491

'location': 'East US',

492

'description': 'Company-wide standardized VM images',

493

'tags': {

494

'department': 'IT',

495

'purpose': 'standardization'

496

}

497

}

498

499

operation = compute_client.galleries.begin_create_or_update(

500

'myResourceGroup',

501

'myCompanyGallery',

502

gallery_parameters

503

)

504

gallery = operation.result()

505

506

# Create image definition in the gallery

507

image_definition_parameters = {

508

'location': 'East US',

509

'description': 'Ubuntu 20.04 with company applications',

510

'os_type': 'Linux',

511

'os_state': 'Generalized',

512

'identifier': {

513

'publisher': 'MyCompany',

514

'offer': 'Ubuntu',

515

'sku': '20.04-LTS-Configured'

516

},

517

'recommended': {

518

'v_cpus': {'min': 2, 'max': 8},

519

'memory': {'min': 4, 'max': 32}

520

}

521

}

522

523

operation = compute_client.gallery_images.begin_create_or_update(

524

'myResourceGroup',

525

'myCompanyGallery',

526

'ubuntu-configured',

527

image_definition_parameters

528

)

529

image_definition = operation.result()

530

print(f"Image definition created: {image_definition.name}")

531

```

532

533

### Create and Distribute Image Version

534

535

```python

536

# Create image version from custom image

537

image_version_parameters = {

538

'location': 'East US',

539

'publishing_profile': {

540

'target_regions': [

541

{

542

'name': 'East US',

543

'replica_count': 1,

544

'storage_account_type': 'Standard_LRS'

545

},

546

{

547

'name': 'West US 2',

548

'replica_count': 2,

549

'storage_account_type': 'Standard_LRS'

550

}

551

],

552

'replica_count': 1,

553

'exclude_from_latest': False,

554

'end_of_life_date': '2025-12-31T23:59:59+00:00'

555

},

556

'storage_profile': {

557

'source': {

558

'id': '/subscriptions/.../images/myCustomImage'

559

}

560

}

561

}

562

563

operation = compute_client.gallery_image_versions.begin_create_or_update(

564

'myResourceGroup',

565

'myCompanyGallery',

566

'ubuntu-configured',

567

'1.0.0',

568

image_version_parameters

569

)

570

image_version = operation.result()

571

572

# Check replication status

573

replication_status = image_version.replication_status

574

print(f"Replication State: {replication_status.aggregated_state}")

575

for region_status in replication_status.summary:

576

print(f" {region_status.region}: {region_status.state} ({region_status.progress}%)")

577

```

578

579

### Create VM from Gallery Image

580

581

```python

582

# Create VM using gallery image version

583

vm_parameters = {

584

'location': 'East US',

585

'hardware_profile': {

586

'vm_size': 'Standard_B2s'

587

},

588

'storage_profile': {

589

'image_reference': {

590

'id': '/subscriptions/.../galleries/myCompanyGallery/images/ubuntu-configured/versions/1.0.0'

591

},

592

'os_disk': {

593

'create_option': 'FromImage',

594

'managed_disk': {

595

'storage_account_type': 'Premium_LRS'

596

}

597

}

598

},

599

'os_profile': {

600

'computer_name': 'vm-from-gallery',

601

'admin_username': 'azureuser',

602

'disable_password_authentication': True,

603

'linux_configuration': {

604

'ssh': {

605

'public_keys': [{

606

'path': '/home/azureuser/.ssh/authorized_keys',

607

'key_data': 'ssh-rsa AAAAB3NzaC1yc2E...'

608

}]

609

}

610

}

611

},

612

'network_profile': {

613

'network_interfaces': [{

614

'id': '/subscriptions/.../networkInterfaces/mynic'

615

}]

616

}

617

}

618

619

operation = compute_client.virtual_machines.begin_create_or_update(

620

'myResourceGroup',

621

'vmFromGallery',

622

vm_parameters

623

)

624

vm = operation.result()

625

print(f"VM created from gallery image: {vm.name}")

626

```

627

628

### Manage Gallery Applications

629

630

```python

631

# Create gallery application for software deployment

632

app_parameters = {

633

'location': 'East US',

634

'description': 'Company database application package',

635

'supported_os_type': 'Linux',

636

'end_of_life_date': '2025-12-31T23:59:59+00:00',

637

'custom_actions': [

638

{

639

'name': 'configure',

640

'script': 'configure.sh',

641

'description': 'Configure application settings',

642

'parameters': [

643

{

644

'name': 'dbConnectionString',

645

'type': 'String',

646

'description': 'Database connection string'

647

}

648

]

649

}

650

]

651

}

652

653

operation = compute_client.gallery_applications.begin_create_or_update(

654

'myResourceGroup',

655

'myCompanyGallery',

656

'database-app',

657

app_parameters

658

)

659

gallery_app = operation.result()

660

print(f"Gallery application created: {gallery_app.name}")

661

```

662

663

## Gallery Application Versions Management

664

665

Management of application versions within gallery applications for software deployment and version control.

666

667

```python { .api }

668

class GalleryApplicationVersionsOperations:

669

def list_by_gallery_application(resource_group_name: str, gallery_name: str, gallery_application_name: str) -> Iterable[GalleryApplicationVersion]: ...

670

def get(resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, *, expand: Optional[ReplicationStatusTypes] = None) -> GalleryApplicationVersion: ...

671

def begin_create_or_update(resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, gallery_application_version: GalleryApplicationVersion) -> LROPoller[GalleryApplicationVersion]: ...

672

def begin_update(resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, gallery_application_version: GalleryApplicationVersionUpdate) -> LROPoller[GalleryApplicationVersion]: ...

673

def begin_delete(resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str) -> LROPoller[None]: ...

674

```