or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

app-service-environments.mdapp-service-plans.mdapplication-configuration.mdcertificates-domains.mddeployment-management.mddiagnostics-monitoring.mdindex.mdkubernetes-environments.mdstatic-sites.mdweb-applications.mdworkflow-management.md

deployment-management.mddocs/

0

# Deployment Management

1

2

Comprehensive deployment operations including source control integration, continuous deployment, deployment slots, backups, and application deployment from various sources.

3

4

## Package Information

5

6

- **Package**: azure-mgmt-web

7

- **Module**: `azure.mgmt.web.operations.WebAppsOperations`

8

- **Access**: `client.web_apps`

9

10

## Core Imports

11

12

```python

13

from azure.mgmt.web import WebSiteManagementClient

14

from azure.mgmt.web.models import (

15

Deployment, BackupRequest, BackupItem, RestoreRequest,

16

SiteSourceControl, SourceControl

17

)

18

from azure.identity import DefaultAzureCredential

19

```

20

21

## Basic Usage

22

23

```python

24

from azure.mgmt.web import WebSiteManagementClient

25

from azure.identity import DefaultAzureCredential

26

27

credential = DefaultAzureCredential()

28

client = WebSiteManagementClient(credential, subscription_id)

29

30

# List all deployments for a web app

31

deployments = client.web_apps.list_deployments(

32

resource_group_name="my-resource-group",

33

name="my-web-app"

34

)

35

36

for deployment in deployments:

37

print(f"Deployment ID: {deployment.id}")

38

print(f"Status: {deployment.status}")

39

print(f"Author: {deployment.author}")

40

print(f"Message: {deployment.message}")

41

```

42

43

## Deployment Operations

44

45

### List Deployments

46

47

Get all deployments for a web application.

48

49

```python { .api }

50

def list_deployments(

51

self,

52

resource_group_name: str,

53

name: str,

54

**kwargs

55

) -> List[Deployment]:

56

"""

57

List all deployments for the specified web app.

58

59

Args:

60

resource_group_name: Name of the resource group

61

name: Name of the web app

62

63

Returns:

64

List of Deployment objects

65

"""

66

```

67

68

**Usage Example:**

69

70

```python

71

# List deployments for a web app

72

deployments = client.web_apps.list_deployments(

73

resource_group_name="my-resource-group",

74

name="my-web-app"

75

)

76

77

for deployment in deployments:

78

print(f"ID: {deployment.id}, Status: {deployment.status}")

79

```

80

81

### Get Deployment

82

83

Retrieve details for a specific deployment.

84

85

```python { .api }

86

def get_deployment(

87

self,

88

resource_group_name: str,

89

name: str,

90

id: str,

91

**kwargs

92

) -> Deployment:

93

"""

94

Get deployment details by ID.

95

96

Args:

97

resource_group_name: Name of the resource group

98

name: Name of the web app

99

id: Deployment ID

100

101

Returns:

102

Deployment object

103

"""

104

```

105

106

### Create Deployment

107

108

Create a new deployment for a web application.

109

110

```python { .api }

111

def create_deployment(

112

self,

113

resource_group_name: str,

114

name: str,

115

id: str,

116

deployment: Deployment,

117

**kwargs

118

) -> Deployment:

119

"""

120

Create a new deployment.

121

122

Args:

123

resource_group_name: Name of the resource group

124

name: Name of the web app

125

id: Deployment ID

126

deployment: Deployment configuration

127

128

Returns:

129

Created Deployment object

130

"""

131

```

132

133

**Usage Example:**

134

135

```python

136

from azure.mgmt.web.models import Deployment

137

from datetime import datetime

138

139

# Create a new deployment

140

deployment_config = Deployment(

141

status=4, # Success status

142

author="Automated Deploy",

143

author_email="deploy@company.com",

144

message="Automated deployment from CI/CD pipeline",

145

start_time=datetime.utcnow(),

146

end_time=datetime.utcnow()

147

)

148

149

deployment = client.web_apps.create_deployment(

150

resource_group_name="my-resource-group",

151

name="my-web-app",

152

id="deployment-001",

153

deployment=deployment_config

154

)

155

```

156

157

### Delete Deployment

158

159

Remove a deployment record.

160

161

```python { .api }

162

def delete_deployment(

163

self,

164

resource_group_name: str,

165

name: str,

166

id: str,

167

**kwargs

168

) -> None:

169

"""

170

Delete a deployment by ID.

171

172

Args:

173

resource_group_name: Name of the resource group

174

name: Name of the web app

175

id: Deployment ID

176

"""

177

```

178

179

## Source Control Integration

180

181

### Get Source Control Configuration

182

183

Retrieve source control settings for a web app.

184

185

```python { .api }

186

def get_source_control(

187

self,

188

resource_group_name: str,

189

name: str,

190

**kwargs

191

) -> SiteSourceControl:

192

"""

193

Get source control configuration.

194

195

Args:

196

resource_group_name: Name of the resource group

197

name: Name of the web app

198

199

Returns:

200

SiteSourceControl object

201

"""

202

```

203

204

### Update Source Control Configuration

205

206

Configure source control integration.

207

208

```python { .api }

209

def create_or_update_source_control(

210

self,

211

resource_group_name: str,

212

name: str,

213

site_source_control: SiteSourceControl,

214

**kwargs

215

) -> SiteSourceControl:

216

"""

217

Create or update source control configuration.

218

219

Args:

220

resource_group_name: Name of the resource group

221

name: Name of the web app

222

site_source_control: Source control configuration

223

224

Returns:

225

Updated SiteSourceControl object

226

"""

227

```

228

229

**Usage Example:**

230

231

```python

232

from azure.mgmt.web.models import SiteSourceControl

233

234

# Configure GitHub integration

235

source_control = SiteSourceControl(

236

repo_url="https://github.com/user/repository.git",

237

branch="main",

238

is_manual_integration=False,

239

is_mercurial=False,

240

deployment_rollback_enabled=True

241

)

242

243

updated_source_control = client.web_apps.create_or_update_source_control(

244

resource_group_name="my-resource-group",

245

name="my-web-app",

246

site_source_control=source_control

247

)

248

```

249

250

### Sync Repository

251

252

Trigger a manual sync from the configured repository.

253

254

```python { .api }

255

def sync_repository(

256

self,

257

resource_group_name: str,

258

name: str,

259

**kwargs

260

) -> None:

261

"""

262

Sync the repository and trigger deployment.

263

264

Args:

265

resource_group_name: Name of the resource group

266

name: Name of the web app

267

"""

268

```

269

270

**Usage Example:**

271

272

```python

273

# Trigger manual repository sync

274

client.web_apps.sync_repository(

275

resource_group_name="my-resource-group",

276

name="my-web-app"

277

)

278

```

279

280

## Backup and Restore Operations

281

282

### Create Backup

283

284

Create a backup of a web application.

285

286

```python { .api }

287

def backup(

288

self,

289

resource_group_name: str,

290

name: str,

291

request: BackupRequest,

292

**kwargs

293

) -> BackupItem:

294

"""

295

Create a backup of the web app.

296

297

Args:

298

resource_group_name: Name of the resource group

299

name: Name of the web app

300

request: Backup configuration

301

302

Returns:

303

BackupItem object representing the created backup

304

"""

305

```

306

307

**Usage Example:**

308

309

```python

310

from azure.mgmt.web.models import BackupRequest, DatabaseBackupSetting

311

312

# Configure backup settings

313

backup_request = BackupRequest(

314

backup_name="automated-backup-001",

315

enabled=True,

316

storage_account_url="https://mystorageaccount.blob.core.windows.net/backups",

317

backup_schedule=BackupSchedule(

318

frequency_interval=1,

319

frequency_unit="Day",

320

keep_at_least_one_backup=True,

321

retention_period_in_days=30

322

),

323

databases=[

324

DatabaseBackupSetting(

325

database_type="SqlAzure",

326

name="MyDatabase",

327

connection_string_name="DefaultConnection"

328

)

329

]

330

)

331

332

# Create backup

333

backup = client.web_apps.backup(

334

resource_group_name="my-resource-group",

335

name="my-web-app",

336

request=backup_request

337

)

338

print(f"Backup created: {backup.name}")

339

```

340

341

### List Backups

342

343

Retrieve all backups for a web application.

344

345

```python { .api }

346

def list_backups(

347

self,

348

resource_group_name: str,

349

name: str,

350

**kwargs

351

) -> List[BackupItem]:

352

"""

353

List all backups for the web app.

354

355

Args:

356

resource_group_name: Name of the resource group

357

name: Name of the web app

358

359

Returns:

360

List of BackupItem objects

361

"""

362

```

363

364

### Restore from Backup

365

366

Restore a web application from a backup.

367

368

```python { .api }

369

def restore(

370

self,

371

resource_group_name: str,

372

name: str,

373

backup_id: str,

374

request: RestoreRequest,

375

**kwargs

376

) -> None:

377

"""

378

Restore web app from backup.

379

380

Args:

381

resource_group_name: Name of the resource group

382

name: Name of the web app

383

backup_id: ID of the backup to restore from

384

request: Restore configuration

385

"""

386

```

387

388

**Usage Example:**

389

390

```python

391

from azure.mgmt.web.models import RestoreRequest

392

393

# Configure restore operation

394

restore_request = RestoreRequest(

395

storage_account_url="https://mystorageaccount.blob.core.windows.net/backups",

396

blob_name="backup-001.zip",

397

overwrite=True,

398

site_name="my-web-app",

399

databases=[

400

DatabaseBackupSetting(

401

database_type="SqlAzure",

402

name="MyDatabase",

403

connection_string_name="DefaultConnection"

404

)

405

]

406

)

407

408

# Restore from backup

409

client.web_apps.restore(

410

resource_group_name="my-resource-group",

411

name="my-web-app",

412

backup_id="backup-001",

413

request=restore_request

414

)

415

```

416

417

## Deployment Slots

418

419

### List Deployment Slots

420

421

Get all deployment slots for a web application.

422

423

```python { .api }

424

def list_slots(

425

self,

426

resource_group_name: str,

427

name: str,

428

**kwargs

429

) -> List[Site]:

430

"""

431

List deployment slots for the web app.

432

433

Args:

434

resource_group_name: Name of the resource group

435

name: Name of the web app

436

437

Returns:

438

List of Site objects representing deployment slots

439

"""

440

```

441

442

### Create Deployment Slot

443

444

Create a new deployment slot.

445

446

```python { .api }

447

def create_or_update_slot(

448

self,

449

resource_group_name: str,

450

name: str,

451

slot: str,

452

site_envelope: Site,

453

**kwargs

454

) -> Site:

455

"""

456

Create or update a deployment slot.

457

458

Args:

459

resource_group_name: Name of the resource group

460

name: Name of the web app

461

slot: Name of the deployment slot

462

site_envelope: Slot configuration

463

464

Returns:

465

Created/updated Site object

466

"""

467

```

468

469

### Swap Deployment Slots

470

471

Swap content between deployment slots.

472

473

```python { .api }

474

def swap_slot(

475

self,

476

resource_group_name: str,

477

name: str,

478

slot_swap_entity: CsmSlotEntity,

479

**kwargs

480

) -> None:

481

"""

482

Swap deployment slots.

483

484

Args:

485

resource_group_name: Name of the resource group

486

name: Name of the web app

487

slot_swap_entity: Slot swap configuration

488

"""

489

```

490

491

**Usage Example:**

492

493

```python

494

# List deployment slots

495

slots = client.web_apps.list_slots(

496

resource_group_name="my-resource-group",

497

name="my-web-app"

498

)

499

500

for slot in slots:

501

print(f"Slot: {slot.name}")

502

503

# Swap staging slot to production

504

from azure.mgmt.web.models import CsmSlotEntity

505

506

swap_config = CsmSlotEntity(

507

target_slot="production",

508

preserve_vnet=True

509

)

510

511

client.web_apps.swap_slot(

512

resource_group_name="my-resource-group",

513

name="my-web-app",

514

slot_swap_entity=swap_config

515

)

516

```

517

518

## Types

519

520

### Deployment

521

522

```python { .api }

523

class Deployment:

524

"""Represents a deployment record."""

525

id: Optional[str]

526

status: Optional[int]

527

message: Optional[str]

528

author: Optional[str]

529

author_email: Optional[str]

530

deployer: Optional[str]

531

start_time: Optional[datetime]

532

end_time: Optional[datetime]

533

active: Optional[bool]

534

details: Optional[str]

535

```

536

537

### BackupRequest

538

539

```python { .api }

540

class BackupRequest:

541

"""Configuration for creating a backup."""

542

backup_name: str

543

enabled: Optional[bool]

544

storage_account_url: str

545

backup_schedule: Optional[BackupSchedule]

546

databases: Optional[List[DatabaseBackupSetting]]

547

```

548

549

### SiteSourceControl

550

551

```python { .api }

552

class SiteSourceControl:

553

"""Source control configuration for a web app."""

554

repo_url: Optional[str]

555

branch: Optional[str]

556

is_manual_integration: Optional[bool]

557

is_mercurial: Optional[bool]

558

deployment_rollback_enabled: Optional[bool]

559

is_git_hub_action: Optional[bool]

560

```