or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

access-control.mdcache-and-credentials.mdconnected-registries.mdindex.mdprivate-networking.mdregistry-management.mdreplication-management.mdwebhook-management.md

webhook-management.mddocs/

0

# Webhook Management

1

2

Registry webhook configuration for receiving HTTP notifications about registry events like image pushes, deletions, quarantine actions, and Helm chart operations. Webhooks enable integration with CI/CD pipelines, security scanning systems, and other automation workflows.

3

4

## Capabilities

5

6

### Webhook Creation and Management

7

8

Create, update, and delete webhooks with comprehensive event filtering, custom headers, and authentication options.

9

10

```python { .api }

11

def begin_create(resource_group_name: str, registry_name: str, webhook_name: str, webhook_create_parameters: WebhookCreateParameters, **kwargs) -> LROPoller[Webhook]:

12

"""

13

Create a webhook for a container registry.

14

15

Parameters:

16

- resource_group_name: str - Name of the resource group

17

- registry_name: str - Name of the registry

18

- webhook_name: str - Name of the webhook

19

- webhook_create_parameters: WebhookCreateParameters - Webhook configuration

20

21

Returns:

22

LROPoller[Webhook] - Long-running operation poller for the webhook

23

"""

24

25

def begin_delete(resource_group_name: str, registry_name: str, webhook_name: str, **kwargs) -> LROPoller[None]:

26

"""

27

Delete a webhook from a container registry.

28

29

Parameters:

30

- resource_group_name: str - Name of the resource group

31

- registry_name: str - Name of the registry

32

- webhook_name: str - Name of the webhook to delete

33

34

Returns:

35

LROPoller[None] - Long-running operation poller

36

"""

37

38

def begin_update(resource_group_name: str, registry_name: str, webhook_name: str, webhook_update_parameters: WebhookUpdateParameters, **kwargs) -> LROPoller[Webhook]:

39

"""

40

Update a webhook for a container registry.

41

42

Parameters:

43

- resource_group_name: str - Name of the resource group

44

- registry_name: str - Name of the registry

45

- webhook_name: str - Name of the webhook to update

46

- webhook_update_parameters: WebhookUpdateParameters - Update parameters

47

48

Returns:

49

LROPoller[Webhook] - Long-running operation poller for the updated webhook

50

"""

51

```

52

53

### Webhook Information and Status

54

55

Retrieve webhook details, list all webhooks for a registry, and monitor webhook configuration and status.

56

57

```python { .api }

58

def get(resource_group_name: str, registry_name: str, webhook_name: str, **kwargs) -> Webhook:

59

"""

60

Get properties of a webhook.

61

62

Parameters:

63

- resource_group_name: str - Name of the resource group

64

- registry_name: str - Name of the registry

65

- webhook_name: str - Name of the webhook

66

67

Returns:

68

Webhook - Webhook resource with complete configuration

69

"""

70

71

def list(resource_group_name: str, registry_name: str, **kwargs) -> ItemPaged[Webhook]:

72

"""

73

List all webhooks for a container registry.

74

75

Parameters:

76

- resource_group_name: str - Name of the resource group

77

- registry_name: str - Name of the registry

78

79

Returns:

80

ItemPaged[Webhook] - Paginated list of all webhooks for the registry

81

"""

82

```

83

84

### Webhook Configuration Management

85

86

Manage webhook callback configuration including endpoint URLs, authentication, and custom headers.

87

88

```python { .api }

89

def get_callback_config(resource_group_name: str, registry_name: str, webhook_name: str, **kwargs) -> CallbackConfig:

90

"""

91

Get callback configuration for a webhook.

92

93

Parameters:

94

- resource_group_name: str - Name of the resource group

95

- registry_name: str - Name of the registry

96

- webhook_name: str - Name of the webhook

97

98

Returns:

99

CallbackConfig - Webhook callback configuration details

100

"""

101

102

def update_callback_config(resource_group_name: str, registry_name: str, webhook_name: str, callback_config: CallbackConfig, **kwargs) -> CallbackConfig:

103

"""

104

Update callback configuration for a webhook.

105

106

Parameters:

107

- resource_group_name: str - Name of the resource group

108

- registry_name: str - Name of the registry

109

- webhook_name: str - Name of the webhook

110

- callback_config: CallbackConfig - New callback configuration

111

112

Returns:

113

CallbackConfig - Updated callback configuration

114

"""

115

```

116

117

### Webhook Events and Testing

118

119

Manage webhook events, retrieve event history, and test webhook connectivity.

120

121

```python { .api }

122

def list_events(resource_group_name: str, registry_name: str, webhook_name: str, **kwargs) -> ItemPaged[Event]:

123

"""

124

List recent events for a webhook.

125

126

Parameters:

127

- resource_group_name: str - Name of the resource group

128

- registry_name: str - Name of the registry

129

- webhook_name: str - Name of the webhook

130

131

Returns:

132

ItemPaged[Event] - Paginated list of recent webhook events

133

"""

134

135

def ping(resource_group_name: str, registry_name: str, webhook_name: str, **kwargs) -> EventInfo:

136

"""

137

Trigger a ping event for a webhook.

138

139

Parameters:

140

- resource_group_name: str - Name of the resource group

141

- registry_name: str - Name of the registry

142

- webhook_name: str - Name of the webhook

143

144

Returns:

145

EventInfo - Information about the ping event

146

"""

147

```

148

149

## Core Model Types

150

151

### Webhook

152

153

```python { .api }

154

class Webhook:

155

"""

156

An object that represents a webhook for a container registry.

157

158

Attributes:

159

- id: str - Resource ID

160

- name: str - Resource name

161

- type: str - Resource type

162

- location: str - Resource location

163

- tags: Dict[str, str] - Resource tags

164

- status: WebhookStatus - Webhook status (enabled/disabled)

165

- scope: str - Repository scope for the webhook

166

- actions: List[WebhookAction] - Event actions that trigger the webhook

167

- provisioning_state: ProvisioningState - Current provisioning state

168

"""

169

```

170

171

### WebhookCreateParameters

172

173

```python { .api }

174

class WebhookCreateParameters:

175

"""

176

Parameters for creating a webhook.

177

178

Attributes:

179

- tags: Dict[str, str] - Resource tags

180

- location: str - Webhook location

181

- service_uri: str - Service URI for the webhook endpoint

182

- custom_headers: Dict[str, str] - Custom headers to include in webhook calls

183

- status: WebhookStatus - Webhook status (enabled/disabled)

184

- scope: str - Repository scope (e.g., 'myrepo:*' or 'myrepo:tag')

185

- actions: List[WebhookAction] - Actions that trigger the webhook

186

"""

187

```

188

189

### WebhookUpdateParameters

190

191

```python { .api }

192

class WebhookUpdateParameters:

193

"""

194

Parameters for updating a webhook.

195

196

Attributes:

197

- tags: Dict[str, str] - Resource tags

198

- service_uri: str - Service URI for the webhook endpoint

199

- custom_headers: Dict[str, str] - Custom headers

200

- status: WebhookStatus - Webhook status

201

- scope: str - Repository scope

202

- actions: List[WebhookAction] - Actions that trigger the webhook

203

"""

204

```

205

206

### CallbackConfig

207

208

```python { .api }

209

class CallbackConfig:

210

"""

211

Configuration for webhook callback.

212

213

Attributes:

214

- service_uri: str - Service endpoint URI

215

- custom_headers: Dict[str, str] - Custom headers sent with webhook calls

216

"""

217

```

218

219

### Event

220

221

```python { .api }

222

class Event:

223

"""

224

Event for a webhook.

225

226

Attributes:

227

- id: str - Event ID

228

- event_request_message: EventRequestMessage - Request message details

229

- event_response_message: EventResponseMessage - Response message details

230

"""

231

```

232

233

### EventRequestMessage

234

235

```python { .api }

236

class EventRequestMessage:

237

"""

238

Event request message for webhook.

239

240

Attributes:

241

- content: EventContent - Event content with registry and action details

242

- headers: Dict[str, str] - Request headers

243

- method: str - HTTP method

244

- request_uri: str - Request URI

245

- version: str - API version

246

"""

247

```

248

249

### EventContent

250

251

```python { .api }

252

class EventContent:

253

"""

254

Content of a webhook event.

255

256

Attributes:

257

- id: str - Event ID

258

- timestamp: datetime - Event timestamp

259

- action: str - Action that triggered the event

260

- target: Dict - Target object (repository, tag, digest details)

261

- request: Dict - Request details (id, addr, host, method, useragent)

262

- actor: Actor - Actor who performed the action

263

- source: Dict - Source registry information

264

"""

265

```

266

267

## Enums

268

269

### WebhookAction

270

271

```python { .api }

272

class WebhookAction(str, Enum):

273

"""Actions that can trigger webhooks."""

274

PUSH = "push"

275

DELETE = "delete"

276

QUARANTINE = "quarantine"

277

CHART_PUSH = "chart_push"

278

CHART_DELETE = "chart_delete"

279

```

280

281

### WebhookStatus

282

283

```python { .api }

284

class WebhookStatus(str, Enum):

285

"""Webhook status options."""

286

ENABLED = "enabled"

287

DISABLED = "disabled"

288

```

289

290

## Usage Examples

291

292

### Create a Webhook for CI/CD Integration

293

294

```python

295

from azure.mgmt.containerregistry import ContainerRegistryManagementClient

296

from azure.mgmt.containerregistry.models import (

297

WebhookCreateParameters, WebhookAction, WebhookStatus

298

)

299

from azure.identity import DefaultAzureCredential

300

301

client = ContainerRegistryManagementClient(

302

DefaultAzureCredential(),

303

"subscription-id"

304

)

305

306

# Create a webhook that triggers on image pushes and deletions

307

webhook_params = WebhookCreateParameters(

308

location="East US",

309

service_uri="https://mycicd.example.com/webhook/registry",

310

status=WebhookStatus.ENABLED,

311

actions=[WebhookAction.PUSH, WebhookAction.DELETE],

312

scope="myapp/*", # Only for repositories starting with 'myapp'

313

custom_headers={

314

"Authorization": "Bearer your-token-here",

315

"X-Source": "azure-container-registry"

316

},

317

tags={

318

"purpose": "cicd-integration",

319

"environment": "production"

320

}

321

)

322

323

# Create the webhook

324

creation_poller = client.webhooks.begin_create(

325

"my-resource-group",

326

"my-registry",

327

"cicd-webhook",

328

webhook_params

329

)

330

331

webhook = creation_poller.result()

332

print(f"Created webhook: {webhook.name}")

333

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

334

print(f"Actions: {webhook.actions}")

335

```

336

337

### Create Security Scanning Webhook

338

339

```python

340

# Create a webhook for security scanning on image pushes

341

security_webhook_params = WebhookCreateParameters(

342

location="East US",

343

service_uri="https://security-scanner.example.com/scan",

344

status=WebhookStatus.ENABLED,

345

actions=[WebhookAction.PUSH], # Only on pushes

346

scope="*", # All repositories

347

custom_headers={

348

"X-API-Key": "your-scanner-api-key",

349

"X-Scan-Type": "vulnerability",

350

"Content-Type": "application/json"

351

},

352

tags={

353

"purpose": "security-scanning",

354

"priority": "high"

355

}

356

)

357

358

security_webhook = client.webhooks.begin_create(

359

"my-resource-group",

360

"my-registry",

361

"security-scanner",

362

security_webhook_params

363

).result()

364

365

print(f"Security webhook created: {security_webhook.name}")

366

```

367

368

### Monitor Webhook Events

369

370

```python

371

# List recent webhook events

372

events = client.webhooks.list_events(

373

"my-resource-group",

374

"my-registry",

375

"cicd-webhook"

376

)

377

378

print("Recent Webhook Events:")

379

print("-" * 40)

380

for event in events:

381

if event.event_request_message and event.event_request_message.content:

382

content = event.event_request_message.content

383

print(f"Event ID: {event.id}")

384

print(f"Action: {content.action}")

385

print(f"Timestamp: {content.timestamp}")

386

print(f"Repository: {content.target.get('repository', 'N/A')}")

387

print(f"Tag: {content.target.get('tag', 'N/A')}")

388

389

if event.event_response_message:

390

print(f"Response Status: {event.event_response_message.status_code}")

391

print("-" * 40)

392

```

393

394

### Test Webhook Connectivity

395

396

```python

397

# Ping webhook to test connectivity

398

ping_result = client.webhooks.ping(

399

"my-resource-group",

400

"my-registry",

401

"cicd-webhook"

402

)

403

404

print(f"Ping Event ID: {ping_result.id}")

405

406

# Check if ping was successful by looking at recent events

407

import time

408

time.sleep(2) # Wait for event to be processed

409

410

recent_events = list(client.webhooks.list_events(

411

"my-resource-group",

412

"my-registry",

413

"cicd-webhook"

414

))

415

416

ping_event = next((e for e in recent_events if e.id == ping_result.id), None)

417

if ping_event and ping_event.event_response_message:

418

status_code = ping_event.event_response_message.status_code

419

print(f"Webhook ping response: {status_code}")

420

if status_code == "200":

421

print("Webhook is responding correctly")

422

else:

423

print(f"Webhook returned error: {status_code}")

424

```

425

426

### Update Webhook Configuration

427

428

```python

429

from azure.mgmt.containerregistry.models import WebhookUpdateParameters

430

431

# Update webhook to include chart operations and change scope

432

update_params = WebhookUpdateParameters(

433

actions=[

434

WebhookAction.PUSH,

435

WebhookAction.DELETE,

436

WebhookAction.CHART_PUSH,

437

WebhookAction.CHART_DELETE

438

],

439

scope="production/*", # Only production repositories

440

custom_headers={

441

"Authorization": "Bearer updated-token",

442

"X-Source": "azure-container-registry",

443

"X-Environment": "production"

444

},

445

tags={

446

"purpose": "cicd-integration",

447

"environment": "production",

448

"updated": "2024-01-15"

449

}

450

)

451

452

updated_webhook = client.webhooks.begin_update(

453

"my-resource-group",

454

"my-registry",

455

"cicd-webhook",

456

update_params

457

).result()

458

459

print(f"Updated webhook actions: {updated_webhook.actions}")

460

print(f"Updated webhook scope: {updated_webhook.scope}")

461

```

462

463

### Manage Multiple Webhooks

464

465

```python

466

# Create webhooks for different purposes

467

webhook_configs = [

468

{

469

"name": "dev-cicd",

470

"scope": "dev/*",

471

"uri": "https://dev-cicd.example.com/webhook",

472

"actions": [WebhookAction.PUSH]

473

},

474

{

475

"name": "prod-cicd",

476

"scope": "prod/*",

477

"uri": "https://prod-cicd.example.com/webhook",

478

"actions": [WebhookAction.PUSH, WebhookAction.DELETE]

479

},

480

{

481

"name": "security-scan",

482

"scope": "*",

483

"uri": "https://security.example.com/scan",

484

"actions": [WebhookAction.PUSH]

485

}

486

]

487

488

created_webhooks = []

489

for config in webhook_configs:

490

webhook_params = WebhookCreateParameters(

491

location="East US",

492

service_uri=config["uri"],

493

status=WebhookStatus.ENABLED,

494

actions=config["actions"],

495

scope=config["scope"],

496

tags={"purpose": config["name"]}

497

)

498

499

webhook = client.webhooks.begin_create(

500

"my-resource-group",

501

"my-registry",

502

config["name"],

503

webhook_params

504

).result()

505

506

created_webhooks.append(webhook)

507

print(f"Created {config['name']}: {webhook.scope} -> {config['uri']}")

508

509

# List all webhooks

510

all_webhooks = client.webhooks.list("my-resource-group", "my-registry")

511

print(f"\nTotal webhooks: {len(list(all_webhooks))}")

512

```