CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-azure-mgmt-network

Microsoft Azure Network Management Client Library for Python

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

load-balancers.mddocs/

Load Balancers

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.

Capabilities

Load Balancer Management

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

class LoadBalancersOperations:
    def begin_create_or_update(self, resource_group_name: str, load_balancer_name: str, parameters: LoadBalancer, **kwargs) -> LROPoller[LoadBalancer]:
        """
        Creates or updates a load balancer.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            parameters (LoadBalancer): Parameters supplied to create or update load balancer
            
        Returns:
            LROPoller[LoadBalancer]: A poller object for the long-running operation
        """
    
    def get(self, resource_group_name: str, load_balancer_name: str, *, expand: Optional[str] = None, **kwargs) -> LoadBalancer:
        """
        Gets the specified load balancer.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            expand (str, optional): Expands referenced resources
            
        Returns:
            LoadBalancer: The load balancer resource
        """
    
    def begin_delete(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> LROPoller[None]:
        """
        Deletes the specified load balancer.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            
        Returns:
            LROPoller[None]: A poller object for the long-running operation
        """
    
    def list(self, resource_group_name: str, **kwargs) -> Iterable[LoadBalancer]:
        """
        Gets all the load balancers in a resource group.
        
        Args:
            resource_group_name (str): The name of the resource group
            
        Returns:
            Iterable[LoadBalancer]: Iterator of load balancers
        """
    
    def list_all(self, **kwargs) -> Iterable[LoadBalancer]:
        """
        Gets all the load balancers in a subscription.
        
        Returns:
            Iterable[LoadBalancer]: Iterator of load balancers
        """
    
    def begin_swap_public_ip_addresses(self, location: str, parameters: LoadBalancerVipSwapRequest, **kwargs) -> LROPoller[None]:
        """
        Swaps VIPs between two load balancers.
        
        Args:
            location (str): The region where load balancers are located
            parameters (LoadBalancerVipSwapRequest): Parameters for VIP swap operation
            
        Returns:
            LROPoller[None]: A poller object for the long-running operation
        """
    
    def migrate_to_ip_based(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> MigratedPools:
        """
        Migrate load balancer to IP Based.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            
        Returns:
            MigratedPools: Information about migrated backend pools
        """

Backend Address Pool Management

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

class LoadBalancerBackendAddressPoolsOperations:
    def begin_create_or_update(self, resource_group_name: str, load_balancer_name: str, backend_address_pool_name: str, parameters: BackendAddressPool, **kwargs) -> LROPoller[BackendAddressPool]:
        """
        Creates or updates a load balancer backend address pool.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            backend_address_pool_name (str): The name of the backend address pool
            parameters (BackendAddressPool): Parameters supplied to create or update backend address pool
            
        Returns:
            LROPoller[BackendAddressPool]: A poller object for the long-running operation
        """
    
    def get(self, resource_group_name: str, load_balancer_name: str, backend_address_pool_name: str, **kwargs) -> BackendAddressPool:
        """
        Gets load balancer backend address pool.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            backend_address_pool_name (str): The name of the backend address pool
            
        Returns:
            BackendAddressPool: The backend address pool resource
        """
    
    def begin_delete(self, resource_group_name: str, load_balancer_name: str, backend_address_pool_name: str, **kwargs) -> LROPoller[None]:
        """
        Deletes the specified load balancer backend address pool.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            backend_address_pool_name (str): The name of the backend address pool
            
        Returns:
            LROPoller[None]: A poller object for the long-running operation
        """
    
    def list(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> Iterable[BackendAddressPool]:
        """
        Gets all the load balancer backend address pools.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            
        Returns:
            Iterable[BackendAddressPool]: Iterator of backend address pools
        """

Frontend IP Configuration Management

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

class LoadBalancerFrontendIPConfigurationsOperations:
    def get(self, resource_group_name: str, load_balancer_name: str, frontend_ip_configuration_name: str, **kwargs) -> FrontendIPConfiguration:
        """
        Gets load balancer frontend IP configuration.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            frontend_ip_configuration_name (str): The name of the frontend IP configuration
            
        Returns:
            FrontendIPConfiguration: The frontend IP configuration resource
        """
    
    def list(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> Iterable[FrontendIPConfiguration]:
        """
        Gets all the load balancer frontend IP configurations.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            
        Returns:
            Iterable[FrontendIPConfiguration]: Iterator of frontend IP configurations
        """

Load Balancing Rules Management

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

class LoadBalancerLoadBalancingRulesOperations:
    def get(self, resource_group_name: str, load_balancer_name: str, load_balancing_rule_name: str, **kwargs) -> LoadBalancingRule:
        """
        Gets the specified load balancing rule.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            load_balancing_rule_name (str): The name of the load balancing rule
            
        Returns:
            LoadBalancingRule: The load balancing rule resource
        """
    
    def list(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> Iterable[LoadBalancingRule]:
        """
        Gets all the load balancing rules in a load balancer.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            
        Returns:
            Iterable[LoadBalancingRule]: Iterator of load balancing rules
        """

Health Probe Management

Manage health probes that monitor the health of backend instances.

class LoadBalancerProbesOperations:
    def get(self, resource_group_name: str, load_balancer_name: str, probe_name: str, **kwargs) -> Probe:
        """
        Gets load balancer probe.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            probe_name (str): The name of the probe
            
        Returns:
            Probe: The probe resource
        """
    
    def list(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> Iterable[Probe]:
        """
        Gets all the load balancer probes.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            
        Returns:
            Iterable[Probe]: Iterator of probes
        """

Inbound NAT Rules Management

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

class InboundNatRulesOperations:
    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]:
        """
        Creates or updates a load balancer inbound NAT rule.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            inbound_nat_rule_name (str): The name of the inbound NAT rule
            inbound_nat_rule_parameters (InboundNatRule): Parameters supplied to create or update inbound NAT rule
            
        Returns:
            LROPoller[InboundNatRule]: A poller object for the long-running operation
        """
    
    def get(self, resource_group_name: str, load_balancer_name: str, inbound_nat_rule_name: str, *, expand: Optional[str] = None, **kwargs) -> InboundNatRule:
        """
        Gets the specified load balancer inbound NAT rule.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            inbound_nat_rule_name (str): The name of the inbound NAT rule
            expand (str, optional): Expands referenced resources
            
        Returns:
            InboundNatRule: The inbound NAT rule resource
        """
    
    def begin_delete(self, resource_group_name: str, load_balancer_name: str, inbound_nat_rule_name: str, **kwargs) -> LROPoller[None]:
        """
        Deletes the specified load balancer inbound NAT rule.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            inbound_nat_rule_name (str): The name of the inbound NAT rule
            
        Returns:
            LROPoller[None]: A poller object for the long-running operation
        """
    
    def list(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> Iterable[InboundNatRule]:
        """
        Gets all the load balancer inbound NAT rules.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            
        Returns:
            Iterable[InboundNatRule]: Iterator of inbound NAT rules
        """

Outbound Rules Management

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

class LoadBalancerOutboundRulesOperations:
    def get(self, resource_group_name: str, load_balancer_name: str, outbound_rule_name: str, **kwargs) -> OutboundRule:
        """
        Gets the specified load balancer outbound rule.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            outbound_rule_name (str): The name of the outbound rule
            
        Returns:
            OutboundRule: The outbound rule resource
        """
    
    def list(self, resource_group_name: str, load_balancer_name: str, **kwargs) -> Iterable[OutboundRule]:
        """
        Gets all the load balancer outbound rules.
        
        Args:
            resource_group_name (str): The name of the resource group
            load_balancer_name (str): The name of the load balancer
            
        Returns:
            Iterable[OutboundRule]: Iterator of outbound rules
        """

Usage Examples

Creating a Standard Load Balancer

from azure.mgmt.network.models import (
    LoadBalancer, LoadBalancerSku, LoadBalancerSkuName, LoadBalancerSkuTier,
    FrontendIPConfiguration, BackendAddressPool, LoadBalancingRule,
    Probe, ProbeProtocol, LoadDistribution, TransportProtocol
)

# Create Standard Load Balancer
lb_params = LoadBalancer(
    location="East US",
    sku=LoadBalancerSku(
        name=LoadBalancerSkuName.STANDARD,
        tier=LoadBalancerSkuTier.REGIONAL
    ),
    frontend_ip_configurations=[
        FrontendIPConfiguration(
            name="frontend",
            public_ip_address={
                "id": "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/publicIPAddresses/lb-pip"
            }
        )
    ],
    backend_address_pools=[
        BackendAddressPool(name="backend-pool")
    ],
    load_balancing_rules=[
        LoadBalancingRule(
            name="web-rule",
            frontend_ip_configuration={
                "id": "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/loadBalancers/my-lb/frontendIPConfigurations/frontend"
            },
            backend_address_pool={
                "id": "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/loadBalancers/my-lb/backendAddressPools/backend-pool"
            },
            probe={
                "id": "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/loadBalancers/my-lb/probes/web-probe"
            },
            protocol=TransportProtocol.TCP,
            frontend_port=80,
            backend_port=80,
            idle_timeout_in_minutes=15,
            enable_floating_ip=False,
            load_distribution=LoadDistribution.DEFAULT
        )
    ],
    probes=[
        Probe(
            name="web-probe",
            protocol=ProbeProtocol.HTTP,
            port=80,
            request_path="/health",
            interval_in_seconds=15,
            number_of_probes=2
        )
    ],
    tags={"Environment": "Production"}
)

# Create the load balancer
operation = client.load_balancers.begin_create_or_update(
    resource_group_name="my-resource-group",
    load_balancer_name="my-lb",
    parameters=lb_params
)
load_balancer = operation.result()

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

Adding Backend Pool Addresses

from azure.mgmt.network.models import LoadBalancerBackendAddress

# Update backend pool with IP addresses
backend_pool_params = BackendAddressPool(
    name="backend-pool",
    load_balancer_backend_addresses=[
        LoadBalancerBackendAddress(
            name="vm1",
            ip_address="10.0.1.4",
            virtual_network={
                "id": "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualNetworks/my-vnet"
            }
        ),
        LoadBalancerBackendAddress(
            name="vm2",
            ip_address="10.0.1.5",
            virtual_network={
                "id": "/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualNetworks/my-vnet"
            }
        )
    ]
)

# Update backend pool
pool_operation = client.load_balancer_backend_address_pools.begin_create_or_update(
    resource_group_name="my-resource-group",
    load_balancer_name="my-lb",
    backend_address_pool_name="backend-pool",
    parameters=backend_pool_params
)
backend_pool = pool_operation.result()

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

Types

class LoadBalancer(Resource):
    def __init__(self, **kwargs): ...
    sku: Optional[LoadBalancerSku]
    frontend_ip_configurations: Optional[List[FrontendIPConfiguration]]
    backend_address_pools: Optional[List[BackendAddressPool]]
    load_balancing_rules: Optional[List[LoadBalancingRule]]
    probes: Optional[List[Probe]]
    inbound_nat_rules: Optional[List[InboundNatRule]]
    inbound_nat_pools: Optional[List[InboundNatPool]]
    outbound_rules: Optional[List[OutboundRule]]
    resource_guid: Optional[str]  # Read-only
    provisioning_state: Optional[ProvisioningState]  # Read-only

class LoadBalancerSku:
    def __init__(self, **kwargs): ...
    name: Optional[LoadBalancerSkuName]
    tier: Optional[LoadBalancerSkuTier]

class FrontendIPConfiguration(SubResource):
    def __init__(self, **kwargs): ...
    inbound_nat_rules: Optional[List[SubResource]]  # Read-only
    inbound_nat_pools: Optional[List[SubResource]]  # Read-only
    outbound_rules: Optional[List[SubResource]]  # Read-only
    load_balancing_rules: Optional[List[SubResource]]  # Read-only
    private_ip_address: Optional[str]
    private_ip_allocation_method: Optional[IPAllocationMethod]
    private_ip_address_version: Optional[IPVersion]
    subnet: Optional[Subnet]
    public_ip_address: Optional[PublicIPAddress]
    public_ip_prefix: Optional[SubResource]
    gateway_load_balancer: Optional[SubResource]
    provisioning_state: Optional[ProvisioningState]  # Read-only
    zones: Optional[List[str]]

class BackendAddressPool(SubResource):
    def __init__(self, **kwargs): ...
    location: Optional[str]
    tunnel_interfaces: Optional[List[GatewayLoadBalancerTunnelInterface]]
    load_balancer_backend_addresses: Optional[List[LoadBalancerBackendAddress]]
    backend_ip_configurations: Optional[List[NetworkInterfaceIPConfiguration]]  # Read-only
    load_balancing_rules: Optional[List[SubResource]]  # Read-only
    outbound_rule: Optional[SubResource]  # Read-only
    outbound_rules: Optional[List[SubResource]]  # Read-only
    inbound_nat_rules: Optional[List[SubResource]]  # Read-only
    provisioning_state: Optional[ProvisioningState]  # Read-only
    drain_period_in_seconds: Optional[int]
    virtual_network: Optional[SubResource]
    sync_mode: Optional[SyncMode]

class LoadBalancingRule(SubResource):
    def __init__(self, **kwargs): ...
    frontend_ip_configuration: Optional[SubResource]
    backend_address_pool: Optional[SubResource]
    backend_address_pools: Optional[List[SubResource]]
    probe: Optional[SubResource]
    protocol: Optional[TransportProtocol]
    load_distribution: Optional[LoadDistribution]
    frontend_port: Optional[int]
    backend_port: Optional[int]
    idle_timeout_in_minutes: Optional[int]
    enable_floating_ip: Optional[bool]
    enable_tcp_reset: Optional[bool]
    disable_outbound_snat: Optional[bool]
    provisioning_state: Optional[ProvisioningState]  # Read-only

class Probe(SubResource):
    def __init__(self, **kwargs): ...
    load_balancing_rules: Optional[List[SubResource]]  # Read-only
    protocol: Optional[ProbeProtocol]
    port: Optional[int]
    interval_in_seconds: Optional[int]
    number_of_probes: Optional[int]
    probe_threshold: Optional[int]
    request_path: Optional[str]
    provisioning_state: Optional[ProvisioningState]  # Read-only

class InboundNatRule(SubResource):
    def __init__(self, **kwargs): ...
    frontend_ip_configuration: Optional[SubResource]
    backend_ip_configuration: Optional[NetworkInterfaceIPConfiguration]  # Read-only
    protocol: Optional[TransportProtocol]
    frontend_port: Optional[int]
    backend_port: Optional[int]
    idle_timeout_in_minutes: Optional[int]
    enable_floating_ip: Optional[bool]
    enable_tcp_reset: Optional[bool]
    frontend_port_range_start: Optional[int]
    frontend_port_range_end: Optional[int]
    backend_address_pool: Optional[SubResource]
    provisioning_state: Optional[ProvisioningState]  # Read-only

class OutboundRule(SubResource):
    def __init__(self, **kwargs): ...
    allocated_outbound_ports: Optional[int]
    frontend_ip_configurations: Optional[List[SubResource]]
    backend_address_pool: Optional[SubResource]
    provisioning_state: Optional[ProvisioningState]  # Read-only
    protocol: Optional[LoadBalancerOutboundRuleProtocol]
    enable_tcp_reset: Optional[bool]
    idle_timeout_in_minutes: Optional[int]

# Enumerations
class LoadBalancerSkuName(str, Enum):
    BASIC = "Basic"
    STANDARD = "Standard"
    GATEWAY = "Gateway"

class LoadBalancerSkuTier(str, Enum):
    REGIONAL = "Regional"
    GLOBAL = "Global"

class LoadDistribution(str, Enum):
    DEFAULT = "Default"
    SOURCE_IP = "SourceIP"
    SOURCE_IP_PROTOCOL = "SourceIPProtocol"

class ProbeProtocol(str, Enum):
    HTTP = "Http"
    HTTPS = "Https"
    TCP = "Tcp"

class TransportProtocol(str, Enum):
    UDP = "Udp"
    TCP = "Tcp"
    ALL = "All"

class LoadBalancerOutboundRuleProtocol(str, Enum):
    TCP = "Tcp"
    UDP = "Udp"
    ALL = "All"

class SyncMode(str, Enum):
    AUTOMATIC = "Automatic"
    MANUAL = "Manual"

Install with Tessl CLI

npx tessl i tessl/pypi-azure-mgmt-network

docs

index.md

load-balancers.md

network-interfaces.md

network-security.md

virtual-networks.md

tile.json