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

virtual-networks.mddocs/

Virtual Networks and Subnets

Azure Virtual Networks (VNets) provide isolated network environments in the cloud. This module provides comprehensive management of virtual networks, subnets, address spaces, network peering, and related networking components.

Capabilities

Virtual Network Management

Create, configure, and manage Azure virtual networks including address spaces, DNS settings, DDoS protection, and service endpoints.

class VirtualNetworksOperations:
    def begin_create_or_update(self, resource_group_name: str, virtual_network_name: str, parameters: VirtualNetwork, **kwargs) -> LROPoller[VirtualNetwork]:
        """
        Creates or updates a virtual network in the specified resource group.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            parameters (VirtualNetwork): Parameters supplied to create or update virtual network
            
        Returns:
            LROPoller[VirtualNetwork]: A poller object for the long-running operation
        """
    
    def get(self, resource_group_name: str, virtual_network_name: str, *, expand: Optional[str] = None, **kwargs) -> VirtualNetwork:
        """
        Gets the specified virtual network by resource group.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            expand (str, optional): Expands referenced resources
            
        Returns:
            VirtualNetwork: The virtual network resource
        """
    
    def begin_delete(self, resource_group_name: str, virtual_network_name: str, **kwargs) -> LROPoller[None]:
        """
        Deletes the specified virtual network.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            
        Returns:
            LROPoller[None]: A poller object for the long-running operation
        """
    
    def list(self, resource_group_name: str, **kwargs) -> Iterable[VirtualNetwork]:
        """
        Gets all virtual networks in a resource group.
        
        Args:
            resource_group_name (str): The name of the resource group
            
        Returns:
            Iterable[VirtualNetwork]: Iterator of virtual networks
        """
    
    def list_all(self, **kwargs) -> Iterable[VirtualNetwork]:
        """
        Gets all virtual networks in a subscription.
        
        Returns:
            Iterable[VirtualNetwork]: Iterator of virtual networks
        """
    
    def check_ip_address_availability(self, resource_group_name: str, virtual_network_name: str, ip_address: str, **kwargs) -> IPAddressAvailabilityResult:
        """
        Checks whether a private IP address is available for use.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            ip_address (str): The private IP address to be verified
            
        Returns:
            IPAddressAvailabilityResult: IP address availability result
        """
    
    def list_usage(self, resource_group_name: str, virtual_network_name: str, **kwargs) -> Iterable[VirtualNetworkUsage]:
        """
        Lists usage stats for the virtual network.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            
        Returns:
            Iterable[VirtualNetworkUsage]: Iterator of usage stats
        """
    
    def update_tags(self, resource_group_name: str, virtual_network_name: str, parameters: TagsObject, **kwargs) -> VirtualNetwork:
        """
        Updates virtual network tags.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            parameters (TagsObject): Parameters supplied to update virtual network tags
            
        Returns:
            VirtualNetwork: The updated virtual network
        """
    
    def begin_list_ddos_protection_status(self, resource_group_name: str, virtual_network_name: str, *, top: Optional[int] = None, skip_token: Optional[str] = None, **kwargs) -> LROPoller[Iterable[PublicIpDdosProtectionStatusResult]]:
        """
        Gets the DDoS Protection Status of all IP Addresses under the Virtual Network.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            top (int, optional): An optional query parameter for the maximum number of results to return
            skip_token (str, optional): SkipToken is only used if a previous operation returned a partial result
            
        Returns:
            LROPoller[Iterable[PublicIpDdosProtectionStatusResult]]: A poller object for the long-running operation
        """

Subnet Management

Manage subnets within virtual networks including address prefixes, network security groups, route tables, and service endpoints.

class SubnetsOperations:
    def begin_create_or_update(self, resource_group_name: str, virtual_network_name: str, subnet_name: str, subnet_parameters: Subnet, **kwargs) -> LROPoller[Subnet]:
        """
        Creates or updates a subnet in the specified virtual network.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            subnet_name (str): The name of the subnet
            subnet_parameters (Subnet): Parameters supplied to create or update subnet
            
        Returns:
            LROPoller[Subnet]: A poller object for the long-running operation
        """
    
    def get(self, resource_group_name: str, virtual_network_name: str, subnet_name: str, *, expand: Optional[str] = None, **kwargs) -> Subnet:
        """
        Gets the specified subnet by virtual network and resource group.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            subnet_name (str): The name of the subnet
            expand (str, optional): Expands referenced resources
            
        Returns:
            Subnet: The subnet resource
        """
    
    def begin_delete(self, resource_group_name: str, virtual_network_name: str, subnet_name: str, **kwargs) -> LROPoller[None]:
        """
        Deletes the specified subnet.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            subnet_name (str): The name of the subnet
            
        Returns:
            LROPoller[None]: A poller object for the long-running operation
        """
    
    def list(self, resource_group_name: str, virtual_network_name: str, **kwargs) -> Iterable[Subnet]:
        """
        Gets all subnets in a virtual network.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            
        Returns:
            Iterable[Subnet]: Iterator of subnets
        """
    
    def begin_prepare_network_policies(self, resource_group_name: str, virtual_network_name: str, subnet_name: str, prepare_network_policies_request_parameters: PrepareNetworkPoliciesRequest, **kwargs) -> LROPoller[None]:
        """
        Prepares a subnet by applying network intent policies.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            subnet_name (str): The name of the subnet
            prepare_network_policies_request_parameters (PrepareNetworkPoliciesRequest): Parameters supplied to prepare subnet
            
        Returns:
            LROPoller[None]: A poller object for the long-running operation
        """
    
    def begin_unprepare_network_policies(self, resource_group_name: str, virtual_network_name: str, subnet_name: str, unprepare_network_policies_request_parameters: UnprepareNetworkPoliciesRequest, **kwargs) -> LROPoller[None]:
        """
        Unprepares a subnet by removing network intent policies.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            subnet_name (str): The name of the subnet
            unprepare_network_policies_request_parameters (UnprepareNetworkPoliciesRequest): Parameters supplied to unprepare subnet
            
        Returns:
            LROPoller[None]: A poller object for the long-running operation
        """

Virtual Network Peering

Manage virtual network peering connections to enable communication between virtual networks.

class VirtualNetworkPeeringsOperations:
    def begin_create_or_update(self, resource_group_name: str, virtual_network_name: str, virtual_network_peering_name: str, virtual_network_peering_parameters: VirtualNetworkPeering, **kwargs) -> LROPoller[VirtualNetworkPeering]:
        """
        Creates or updates a peering in the specified virtual network.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            virtual_network_peering_name (str): The name of the peering
            virtual_network_peering_parameters (VirtualNetworkPeering): Parameters supplied to create or update virtual network peering
            
        Returns:
            LROPoller[VirtualNetworkPeering]: A poller object for the long-running operation
        """
    
    def get(self, resource_group_name: str, virtual_network_name: str, virtual_network_peering_name: str, **kwargs) -> VirtualNetworkPeering:
        """
        Gets the specified virtual network peering.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            virtual_network_peering_name (str): The name of the virtual network peering
            
        Returns:
            VirtualNetworkPeering: The virtual network peering resource
        """
    
    def begin_delete(self, resource_group_name: str, virtual_network_name: str, virtual_network_peering_name: str, **kwargs) -> LROPoller[None]:
        """
        Deletes the specified virtual network peering.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            virtual_network_peering_name (str): The name of the virtual network peering
            
        Returns:
            LROPoller[None]: A poller object for the long-running operation
        """
    
    def list(self, resource_group_name: str, virtual_network_name: str, **kwargs) -> Iterable[VirtualNetworkPeering]:
        """
        Gets all virtual network peerings in a virtual network.
        
        Args:
            resource_group_name (str): The name of the resource group
            virtual_network_name (str): The name of the virtual network
            
        Returns:
            Iterable[VirtualNetworkPeering]: Iterator of virtual network peerings
        """

Usage Examples

Creating a Virtual Network with Subnets

from azure.mgmt.network.models import (
    VirtualNetwork, AddressSpace, Subnet, DhcpOptions
)

# Define virtual network parameters
vnet_params = VirtualNetwork(
    location="East US",
    address_space=AddressSpace(
        address_prefixes=["10.0.0.0/16"]
    ),
    dhcp_options=DhcpOptions(
        dns_servers=["8.8.8.8", "8.8.4.4"]
    ),
    subnets=[
        Subnet(
            name="default",
            address_prefix="10.0.1.0/24"
        ),
        Subnet(
            name="web-tier",
            address_prefix="10.0.2.0/24"
        ),
        Subnet(
            name="app-tier", 
            address_prefix="10.0.3.0/24"
        )
    ],
    tags={"Environment": "Production", "Team": "Networking"}
)

# Create virtual network
operation = client.virtual_networks.begin_create_or_update(
    resource_group_name="my-resource-group",
    virtual_network_name="my-vnet",
    parameters=vnet_params
)
vnet = operation.result()

print(f"Created VNet: {vnet.name} with {len(vnet.subnets)} subnets")

Setting up Virtual Network Peering

from azure.mgmt.network.models import VirtualNetworkPeering

# Create peering from VNet1 to VNet2
peering_params = VirtualNetworkPeering(
    allow_virtual_network_access=True,
    allow_forwarded_traffic=False,
    allow_gateway_transit=False,
    use_remote_gateways=False,
    remote_virtual_network={
        "id": "/subscriptions/{subscription-id}/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/vnet2"
    }
)

# Create the peering
peering_operation = client.virtual_network_peerings.begin_create_or_update(
    resource_group_name="rg1",
    virtual_network_name="vnet1",
    virtual_network_peering_name="vnet1-to-vnet2",
    virtual_network_peering_parameters=peering_params
)
peering = peering_operation.result()

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

Types

class VirtualNetwork(Resource):
    def __init__(self, **kwargs): ...
    address_space: Optional[AddressSpace]
    dhcp_options: Optional[DhcpOptions]
    subnets: Optional[List[Subnet]]
    virtual_network_peerings: Optional[List[VirtualNetworkPeering]]
    resource_guid: Optional[str]  # Read-only
    provisioning_state: Optional[ProvisioningState]  # Read-only
    enable_ddos_protection: Optional[bool]
    enable_vm_protection: Optional[bool]
    ddos_protection_plan: Optional[SubResource]
    bgp_communities: Optional[VirtualNetworkBgpCommunities]
    ip_allocations: Optional[List[SubResource]]
    flow_timeout_in_minutes: Optional[int]

class Subnet(SubResource):
    def __init__(self, **kwargs): ...
    address_prefix: Optional[str]
    address_prefixes: Optional[List[str]]
    network_security_group: Optional[NetworkSecurityGroup]
    route_table: Optional[RouteTable]
    nat_gateway: Optional[SubResource]
    service_endpoints: Optional[List[ServiceEndpointPropertiesFormat]]
    service_endpoint_policies: Optional[List[ServiceEndpointPolicy]]
    private_endpoints: Optional[List[PrivateEndpoint]]  # Read-only
    ip_configurations: Optional[List[IPConfiguration]]  # Read-only
    resource_navigation_links: Optional[List[ResourceNavigationLink]]  # Read-only
    service_association_links: Optional[List[ServiceAssociationLink]]  # Read-only
    delegations: Optional[List[Delegation]]
    purpose: Optional[str]  # Read-only
    provisioning_state: Optional[ProvisioningState]  # Read-only
    private_endpoint_network_policies: Optional[VirtualNetworkPrivateEndpointNetworkPolicies]
    private_link_service_network_policies: Optional[VirtualNetworkPrivateLinkServiceNetworkPolicies]
    application_gateway_ip_configurations: Optional[List[ApplicationGatewayIPConfiguration]]  # Read-only

class VirtualNetworkPeering(SubResource):
    def __init__(self, **kwargs): ...
    allow_virtual_network_access: Optional[bool]
    allow_forwarded_traffic: Optional[bool]
    allow_gateway_transit: Optional[bool]
    use_remote_gateways: Optional[bool]
    remote_virtual_network: Optional[SubResource]
    remote_address_space: Optional[AddressSpace]  # Read-only
    remote_bgp_communities: Optional[VirtualNetworkBgpCommunities]  # Read-only
    peering_state: Optional[VirtualNetworkPeeringState]  # Read-only
    peering_sync_level: Optional[VirtualNetworkPeeringLevel]  # Read-only
    provisioning_state: Optional[ProvisioningState]  # Read-only
    do_not_verify_remote_gateways: Optional[bool]

class AddressSpace:
    def __init__(self, **kwargs): ...
    address_prefixes: Optional[List[str]]

class DhcpOptions:
    def __init__(self, **kwargs): ...
    dns_servers: Optional[List[str]]

# Enumerations
class VirtualNetworkPeeringState(str, Enum):
    INITIATED = "Initiated"
    CONNECTED = "Connected"
    DISCONNECTED = "Disconnected"

class VirtualNetworkPeeringLevel(str, Enum):
    FULLY_IN_SYNC = "FullyInSync"
    REMOTE_NOT_IN_SYNC = "RemoteNotInSync"
    LOCAL_NOT_IN_SYNC = "LocalNotInSync"
    LOCAL_AND_REMOTE_NOT_IN_SYNC = "LocalAndRemoteNotInSync"

class VirtualNetworkPrivateEndpointNetworkPolicies(str, Enum):
    ENABLED = "Enabled"
    DISABLED = "Disabled"

class VirtualNetworkPrivateLinkServiceNetworkPolicies(str, Enum):
    ENABLED = "Enabled"
    DISABLED = "Disabled"

class TagsObject:
    def __init__(self, **kwargs): ...
    tags: Optional[Dict[str, str]]

class IPAddressAvailabilityResult:
    def __init__(self, **kwargs): ...
    available: Optional[bool]  # Read-only
    available_ip_addresses: Optional[List[str]]  # Read-only
    is_platform_reserved: Optional[bool]  # Read-only

class VirtualNetworkUsage:
    def __init__(self, **kwargs): ...
    current_value: Optional[float]  # Read-only
    id: Optional[str]  # Read-only
    limit: Optional[float]  # Read-only
    name: Optional[VirtualNetworkUsageName]  # Read-only
    unit: Optional[str]  # Read-only

class VirtualNetworkUsageName:
    def __init__(self, **kwargs): ...
    localized_value: Optional[str]  # Read-only
    value: Optional[str]  # Read-only

class PublicIpDdosProtectionStatusResult:
    def __init__(self, **kwargs): ...
    ddos_protection_plan_id: Optional[str]  # Read-only
    is_workload_protected: Optional[PublicIpDdosProtectionStatusType]  # Read-only
    public_ip_address: Optional[str]  # Read-only
    public_ip_address_id: Optional[str]  # Read-only

class PublicIpDdosProtectionStatusType(str, Enum):
    PROTECTED = "Protected"
    UNPROTECTED = "Unprotected"
    NOT_COVERED = "NotCovered"

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