or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

index.mdload-balancers.mdnetwork-interfaces.mdnetwork-security.mdvirtual-networks.md

load-balancers.mddocs/

0

# Load Balancers

1

2

Azure Load Balancer distributes inbound traffic among healthy virtual machine instances. This module provides comprehensive management of load balancers, backend pools, frontend configurations, load balancing rules, health probes, and NAT rules.

3

4

## Capabilities

5

6

### Load Balancer Management

7

8

Create and manage Azure Load Balancers including Basic, Standard, and Gateway SKUs with support for internal and external configurations.

9

10

```python { .api }

11

class LoadBalancersOperations:

12

def begin_create_or_update(self, resource_group_name: str, load_balancer_name: str, parameters: LoadBalancer, **kwargs) -> LROPoller[LoadBalancer]:

13

"""

14

Creates or updates a load balancer.

15

16

Args:

17

resource_group_name (str): The name of the resource group

18

load_balancer_name (str): The name of the load balancer

19

parameters (LoadBalancer): Parameters supplied to create or update load balancer

20

21

Returns:

22

LROPoller[LoadBalancer]: A poller object for the long-running operation

23

"""

24

25

def get(self, resource_group_name: str, load_balancer_name: str, *, expand: Optional[str] = None, **kwargs) -> LoadBalancer:

26

"""

27

Gets the specified load balancer.

28

29

Args:

30

resource_group_name (str): The name of the resource group

31

load_balancer_name (str): The name of the load balancer

32

expand (str, optional): Expands referenced resources

33

34

Returns:

35

LoadBalancer: The load balancer resource

36

"""

37

38

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

39

"""

40

Deletes the specified load balancer.

41

42

Args:

43

resource_group_name (str): The name of the resource group

44

load_balancer_name (str): The name of the load balancer

45

46

Returns:

47

LROPoller[None]: A poller object for the long-running operation

48

"""

49

50

def list(self, resource_group_name: str, **kwargs) -> Iterable[LoadBalancer]:

51

"""

52

Gets all the load balancers in a resource group.

53

54

Args:

55

resource_group_name (str): The name of the resource group

56

57

Returns:

58

Iterable[LoadBalancer]: Iterator of load balancers

59

"""

60

61

def list_all(self, **kwargs) -> Iterable[LoadBalancer]:

62

"""

63

Gets all the load balancers in a subscription.

64

65

Returns:

66

Iterable[LoadBalancer]: Iterator of load balancers

67

"""

68

69

def begin_swap_public_ip_addresses(self, location: str, parameters: LoadBalancerVipSwapRequest, **kwargs) -> LROPoller[None]:

70

"""

71

Swaps VIPs between two load balancers.

72

73

Args:

74

location (str): The region where load balancers are located

75

parameters (LoadBalancerVipSwapRequest): Parameters for VIP swap operation

76

77

Returns:

78

LROPoller[None]: A poller object for the long-running operation

79

"""

80

81

def migrate_to_ip_based(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> MigratedPools:

82

"""

83

Migrate load balancer to IP Based.

84

85

Args:

86

resource_group_name (str): The name of the resource group

87

load_balancer_name (str): The name of the load balancer

88

89

Returns:

90

MigratedPools: Information about migrated backend pools

91

"""

92

```

93

94

### Backend Address Pool Management

95

96

Manage backend address pools that contain the target virtual machines or virtual machine scale sets.

97

98

```python { .api }

99

class LoadBalancerBackendAddressPoolsOperations:

100

def begin_create_or_update(self, resource_group_name: str, load_balancer_name: str, backend_address_pool_name: str, parameters: BackendAddressPool, **kwargs) -> LROPoller[BackendAddressPool]:

101

"""

102

Creates or updates a load balancer backend address pool.

103

104

Args:

105

resource_group_name (str): The name of the resource group

106

load_balancer_name (str): The name of the load balancer

107

backend_address_pool_name (str): The name of the backend address pool

108

parameters (BackendAddressPool): Parameters supplied to create or update backend address pool

109

110

Returns:

111

LROPoller[BackendAddressPool]: A poller object for the long-running operation

112

"""

113

114

def get(self, resource_group_name: str, load_balancer_name: str, backend_address_pool_name: str, **kwargs) -> BackendAddressPool:

115

"""

116

Gets load balancer backend address pool.

117

118

Args:

119

resource_group_name (str): The name of the resource group

120

load_balancer_name (str): The name of the load balancer

121

backend_address_pool_name (str): The name of the backend address pool

122

123

Returns:

124

BackendAddressPool: The backend address pool resource

125

"""

126

127

def begin_delete(self, resource_group_name: str, load_balancer_name: str, backend_address_pool_name: str, **kwargs) -> LROPoller[None]:

128

"""

129

Deletes the specified load balancer backend address pool.

130

131

Args:

132

resource_group_name (str): The name of the resource group

133

load_balancer_name (str): The name of the load balancer

134

backend_address_pool_name (str): The name of the backend address pool

135

136

Returns:

137

LROPoller[None]: A poller object for the long-running operation

138

"""

139

140

def list(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> Iterable[BackendAddressPool]:

141

"""

142

Gets all the load balancer backend address pools.

143

144

Args:

145

resource_group_name (str): The name of the resource group

146

load_balancer_name (str): The name of the load balancer

147

148

Returns:

149

Iterable[BackendAddressPool]: Iterator of backend address pools

150

"""

151

```

152

153

### Frontend IP Configuration Management

154

155

Manage frontend IP configurations that define the load balancer's public or private IP addresses.

156

157

```python { .api }

158

class LoadBalancerFrontendIPConfigurationsOperations:

159

def get(self, resource_group_name: str, load_balancer_name: str, frontend_ip_configuration_name: str, **kwargs) -> FrontendIPConfiguration:

160

"""

161

Gets load balancer frontend IP configuration.

162

163

Args:

164

resource_group_name (str): The name of the resource group

165

load_balancer_name (str): The name of the load balancer

166

frontend_ip_configuration_name (str): The name of the frontend IP configuration

167

168

Returns:

169

FrontendIPConfiguration: The frontend IP configuration resource

170

"""

171

172

def list(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> Iterable[FrontendIPConfiguration]:

173

"""

174

Gets all the load balancer frontend IP configurations.

175

176

Args:

177

resource_group_name (str): The name of the resource group

178

load_balancer_name (str): The name of the load balancer

179

180

Returns:

181

Iterable[FrontendIPConfiguration]: Iterator of frontend IP configurations

182

"""

183

```

184

185

### Load Balancing Rules Management

186

187

Configure load balancing rules that define how traffic is distributed to backend instances.

188

189

```python { .api }

190

class LoadBalancerLoadBalancingRulesOperations:

191

def get(self, resource_group_name: str, load_balancer_name: str, load_balancing_rule_name: str, **kwargs) -> LoadBalancingRule:

192

"""

193

Gets the specified load balancing rule.

194

195

Args:

196

resource_group_name (str): The name of the resource group

197

load_balancer_name (str): The name of the load balancer

198

load_balancing_rule_name (str): The name of the load balancing rule

199

200

Returns:

201

LoadBalancingRule: The load balancing rule resource

202

"""

203

204

def list(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> Iterable[LoadBalancingRule]:

205

"""

206

Gets all the load balancing rules in a load balancer.

207

208

Args:

209

resource_group_name (str): The name of the resource group

210

load_balancer_name (str): The name of the load balancer

211

212

Returns:

213

Iterable[LoadBalancingRule]: Iterator of load balancing rules

214

"""

215

```

216

217

### Health Probe Management

218

219

Manage health probes that monitor the health of backend instances.

220

221

```python { .api }

222

class LoadBalancerProbesOperations:

223

def get(self, resource_group_name: str, load_balancer_name: str, probe_name: str, **kwargs) -> Probe:

224

"""

225

Gets load balancer probe.

226

227

Args:

228

resource_group_name (str): The name of the resource group

229

load_balancer_name (str): The name of the load balancer

230

probe_name (str): The name of the probe

231

232

Returns:

233

Probe: The probe resource

234

"""

235

236

def list(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> Iterable[Probe]:

237

"""

238

Gets all the load balancer probes.

239

240

Args:

241

resource_group_name (str): The name of the resource group

242

load_balancer_name (str): The name of the load balancer

243

244

Returns:

245

Iterable[Probe]: Iterator of probes

246

"""

247

```

248

249

### Inbound NAT Rules Management

250

251

Configure inbound NAT rules for direct access to specific backend instances.

252

253

```python { .api }

254

class InboundNatRulesOperations:

255

def begin_create_or_update(self, resource_group_name: str, load_balancer_name: str, inbound_nat_rule_name: str, inbound_nat_rule_parameters: InboundNatRule, **kwargs) -> LROPoller[InboundNatRule]:

256

"""

257

Creates or updates a load balancer inbound NAT rule.

258

259

Args:

260

resource_group_name (str): The name of the resource group

261

load_balancer_name (str): The name of the load balancer

262

inbound_nat_rule_name (str): The name of the inbound NAT rule

263

inbound_nat_rule_parameters (InboundNatRule): Parameters supplied to create or update inbound NAT rule

264

265

Returns:

266

LROPoller[InboundNatRule]: A poller object for the long-running operation

267

"""

268

269

def get(self, resource_group_name: str, load_balancer_name: str, inbound_nat_rule_name: str, *, expand: Optional[str] = None, **kwargs) -> InboundNatRule:

270

"""

271

Gets the specified load balancer inbound NAT rule.

272

273

Args:

274

resource_group_name (str): The name of the resource group

275

load_balancer_name (str): The name of the load balancer

276

inbound_nat_rule_name (str): The name of the inbound NAT rule

277

expand (str, optional): Expands referenced resources

278

279

Returns:

280

InboundNatRule: The inbound NAT rule resource

281

"""

282

283

def begin_delete(self, resource_group_name: str, load_balancer_name: str, inbound_nat_rule_name: str, **kwargs) -> LROPoller[None]:

284

"""

285

Deletes the specified load balancer inbound NAT rule.

286

287

Args:

288

resource_group_name (str): The name of the resource group

289

load_balancer_name (str): The name of the load balancer

290

inbound_nat_rule_name (str): The name of the inbound NAT rule

291

292

Returns:

293

LROPoller[None]: A poller object for the long-running operation

294

"""

295

296

def list(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> Iterable[InboundNatRule]:

297

"""

298

Gets all the load balancer inbound NAT rules.

299

300

Args:

301

resource_group_name (str): The name of the resource group

302

load_balancer_name (str): The name of the load balancer

303

304

Returns:

305

Iterable[InboundNatRule]: Iterator of inbound NAT rules

306

"""

307

```

308

309

### Outbound Rules Management

310

311

Configure outbound rules for Standard Load Balancer to provide outbound connectivity.

312

313

```python { .api }

314

class LoadBalancerOutboundRulesOperations:

315

def get(self, resource_group_name: str, load_balancer_name: str, outbound_rule_name: str, **kwargs) -> OutboundRule:

316

"""

317

Gets the specified load balancer outbound rule.

318

319

Args:

320

resource_group_name (str): The name of the resource group

321

load_balancer_name (str): The name of the load balancer

322

outbound_rule_name (str): The name of the outbound rule

323

324

Returns:

325

OutboundRule: The outbound rule resource

326

"""

327

328

def list(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> Iterable[OutboundRule]:

329

"""

330

Gets all the load balancer outbound rules.

331

332

Args:

333

resource_group_name (str): The name of the resource group

334

load_balancer_name (str): The name of the load balancer

335

336

Returns:

337

Iterable[OutboundRule]: Iterator of outbound rules

338

"""

339

```

340

341

## Usage Examples

342

343

### Creating a Standard Load Balancer

344

345

```python

346

from azure.mgmt.network.models import (

347

LoadBalancer, LoadBalancerSku, LoadBalancerSkuName, LoadBalancerSkuTier,

348

FrontendIPConfiguration, BackendAddressPool, LoadBalancingRule,

349

Probe, ProbeProtocol, LoadDistribution, TransportProtocol

350

)

351

352

# Create Standard Load Balancer

353

lb_params = LoadBalancer(

354

location="East US",

355

sku=LoadBalancerSku(

356

name=LoadBalancerSkuName.STANDARD,

357

tier=LoadBalancerSkuTier.REGIONAL

358

),

359

frontend_ip_configurations=[

360

FrontendIPConfiguration(

361

name="frontend",

362

public_ip_address={

363

"id": "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/publicIPAddresses/lb-pip"

364

}

365

)

366

],

367

backend_address_pools=[

368

BackendAddressPool(name="backend-pool")

369

],

370

load_balancing_rules=[

371

LoadBalancingRule(

372

name="web-rule",

373

frontend_ip_configuration={

374

"id": "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/loadBalancers/my-lb/frontendIPConfigurations/frontend"

375

},

376

backend_address_pool={

377

"id": "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/loadBalancers/my-lb/backendAddressPools/backend-pool"

378

},

379

probe={

380

"id": "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/loadBalancers/my-lb/probes/web-probe"

381

},

382

protocol=TransportProtocol.TCP,

383

frontend_port=80,

384

backend_port=80,

385

idle_timeout_in_minutes=15,

386

enable_floating_ip=False,

387

load_distribution=LoadDistribution.DEFAULT

388

)

389

],

390

probes=[

391

Probe(

392

name="web-probe",

393

protocol=ProbeProtocol.HTTP,

394

port=80,

395

request_path="/health",

396

interval_in_seconds=15,

397

number_of_probes=2

398

)

399

],

400

tags={"Environment": "Production"}

401

)

402

403

# Create the load balancer

404

operation = client.load_balancers.begin_create_or_update(

405

resource_group_name="my-resource-group",

406

load_balancer_name="my-lb",

407

parameters=lb_params

408

)

409

load_balancer = operation.result()

410

411

print(f"Created load balancer: {load_balancer.name}")

412

```

413

414

### Adding Backend Pool Addresses

415

416

```python

417

from azure.mgmt.network.models import LoadBalancerBackendAddress

418

419

# Update backend pool with IP addresses

420

backend_pool_params = BackendAddressPool(

421

name="backend-pool",

422

load_balancer_backend_addresses=[

423

LoadBalancerBackendAddress(

424

name="vm1",

425

ip_address="10.0.1.4",

426

virtual_network={

427

"id": "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualNetworks/my-vnet"

428

}

429

),

430

LoadBalancerBackendAddress(

431

name="vm2",

432

ip_address="10.0.1.5",

433

virtual_network={

434

"id": "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualNetworks/my-vnet"

435

}

436

)

437

]

438

)

439

440

# Update backend pool

441

pool_operation = client.load_balancer_backend_address_pools.begin_create_or_update(

442

resource_group_name="my-resource-group",

443

load_balancer_name="my-lb",

444

backend_address_pool_name="backend-pool",

445

parameters=backend_pool_params

446

)

447

backend_pool = pool_operation.result()

448

449

print(f"Updated backend pool with {len(backend_pool.load_balancer_backend_addresses)} addresses")

450

```

451

452

## Types

453

454

```python { .api }

455

class LoadBalancer(Resource):

456

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

457

sku: Optional[LoadBalancerSku]

458

frontend_ip_configurations: Optional[List[FrontendIPConfiguration]]

459

backend_address_pools: Optional[List[BackendAddressPool]]

460

load_balancing_rules: Optional[List[LoadBalancingRule]]

461

probes: Optional[List[Probe]]

462

inbound_nat_rules: Optional[List[InboundNatRule]]

463

inbound_nat_pools: Optional[List[InboundNatPool]]

464

outbound_rules: Optional[List[OutboundRule]]

465

resource_guid: Optional[str] # Read-only

466

provisioning_state: Optional[ProvisioningState] # Read-only

467

468

class LoadBalancerSku:

469

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

470

name: Optional[LoadBalancerSkuName]

471

tier: Optional[LoadBalancerSkuTier]

472

473

class FrontendIPConfiguration(SubResource):

474

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

475

inbound_nat_rules: Optional[List[SubResource]] # Read-only

476

inbound_nat_pools: Optional[List[SubResource]] # Read-only

477

outbound_rules: Optional[List[SubResource]] # Read-only

478

load_balancing_rules: Optional[List[SubResource]] # Read-only

479

private_ip_address: Optional[str]

480

private_ip_allocation_method: Optional[IPAllocationMethod]

481

private_ip_address_version: Optional[IPVersion]

482

subnet: Optional[Subnet]

483

public_ip_address: Optional[PublicIPAddress]

484

public_ip_prefix: Optional[SubResource]

485

gateway_load_balancer: Optional[SubResource]

486

provisioning_state: Optional[ProvisioningState] # Read-only

487

zones: Optional[List[str]]

488

489

class BackendAddressPool(SubResource):

490

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

491

location: Optional[str]

492

tunnel_interfaces: Optional[List[GatewayLoadBalancerTunnelInterface]]

493

load_balancer_backend_addresses: Optional[List[LoadBalancerBackendAddress]]

494

backend_ip_configurations: Optional[List[NetworkInterfaceIPConfiguration]] # Read-only

495

load_balancing_rules: Optional[List[SubResource]] # Read-only

496

outbound_rule: Optional[SubResource] # Read-only

497

outbound_rules: Optional[List[SubResource]] # Read-only

498

inbound_nat_rules: Optional[List[SubResource]] # Read-only

499

provisioning_state: Optional[ProvisioningState] # Read-only

500

drain_period_in_seconds: Optional[int]

501

virtual_network: Optional[SubResource]

502

sync_mode: Optional[SyncMode]

503

504

class LoadBalancingRule(SubResource):

505

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

506

frontend_ip_configuration: Optional[SubResource]

507

backend_address_pool: Optional[SubResource]

508

backend_address_pools: Optional[List[SubResource]]

509

probe: Optional[SubResource]

510

protocol: Optional[TransportProtocol]

511

load_distribution: Optional[LoadDistribution]

512

frontend_port: Optional[int]

513

backend_port: Optional[int]

514

idle_timeout_in_minutes: Optional[int]

515

enable_floating_ip: Optional[bool]

516

enable_tcp_reset: Optional[bool]

517

disable_outbound_snat: Optional[bool]

518

provisioning_state: Optional[ProvisioningState] # Read-only

519

520

class Probe(SubResource):

521

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

522

load_balancing_rules: Optional[List[SubResource]] # Read-only

523

protocol: Optional[ProbeProtocol]

524

port: Optional[int]

525

interval_in_seconds: Optional[int]

526

number_of_probes: Optional[int]

527

probe_threshold: Optional[int]

528

request_path: Optional[str]

529

provisioning_state: Optional[ProvisioningState] # Read-only

530

531

class InboundNatRule(SubResource):

532

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

533

frontend_ip_configuration: Optional[SubResource]

534

backend_ip_configuration: Optional[NetworkInterfaceIPConfiguration] # Read-only

535

protocol: Optional[TransportProtocol]

536

frontend_port: Optional[int]

537

backend_port: Optional[int]

538

idle_timeout_in_minutes: Optional[int]

539

enable_floating_ip: Optional[bool]

540

enable_tcp_reset: Optional[bool]

541

frontend_port_range_start: Optional[int]

542

frontend_port_range_end: Optional[int]

543

backend_address_pool: Optional[SubResource]

544

provisioning_state: Optional[ProvisioningState] # Read-only

545

546

class OutboundRule(SubResource):

547

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

548

allocated_outbound_ports: Optional[int]

549

frontend_ip_configurations: Optional[List[SubResource]]

550

backend_address_pool: Optional[SubResource]

551

provisioning_state: Optional[ProvisioningState] # Read-only

552

protocol: Optional[LoadBalancerOutboundRuleProtocol]

553

enable_tcp_reset: Optional[bool]

554

idle_timeout_in_minutes: Optional[int]

555

556

# Enumerations

557

class LoadBalancerSkuName(str, Enum):

558

BASIC = "Basic"

559

STANDARD = "Standard"

560

GATEWAY = "Gateway"

561

562

class LoadBalancerSkuTier(str, Enum):

563

REGIONAL = "Regional"

564

GLOBAL = "Global"

565

566

class LoadDistribution(str, Enum):

567

DEFAULT = "Default"

568

SOURCE_IP = "SourceIP"

569

SOURCE_IP_PROTOCOL = "SourceIPProtocol"

570

571

class ProbeProtocol(str, Enum):

572

HTTP = "Http"

573

HTTPS = "Https"

574

TCP = "Tcp"

575

576

class TransportProtocol(str, Enum):

577

UDP = "Udp"

578

TCP = "Tcp"

579

ALL = "All"

580

581

class LoadBalancerOutboundRuleProtocol(str, Enum):

582

TCP = "Tcp"

583

UDP = "Udp"

584

ALL = "All"

585

586

class SyncMode(str, Enum):

587

AUTOMATIC = "Automatic"

588

MANUAL = "Manual"

589

```