Virtual Network
Introduction
Section titled “Introduction”Azure Virtual Network (VNet) is the core networking service for isolating and routing Azure resources in private IP address spaces. It lets you define address ranges, create subnets, and control network behavior for applications. VNets are commonly used to model secure, segmented network topologies in cloud environments.
LocalStack for Azure allows you to build and test Virtual Network workflows in your local environment. The supported APIs are available on our API Coverage section, which provides information on the extent of Virtual Network’s integration with LocalStack.
Getting started
Section titled “Getting started”This guide is designed for users new to Virtual Network and assumes basic knowledge of the Azure CLI and our azlocal wrapper script.
Start your LocalStack container using your preferred method. Then start CLI interception:
azlocal start_interceptionCreate a resource group
Section titled “Create a resource group”Create a resource group for your networking resources:
az group create \ --name rg-vnet-demo \ --location westeurope{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-vnet-demo", "location": "westeurope", "managedBy": null, "name": "rg-vnet-demo", "properties": { "provisioningState": "Succeeded" }, ...}Create and inspect a virtual network
Section titled “Create and inspect a virtual network”Create a VNet with a 10.0.0.0/16 address space:
az network vnet create \ --name vnet-doc78 \ --resource-group rg-vnet-demo \ --location westeurope \ --address-prefixes 10.0.0.0/16{ "newVNet": { "name": "vnet-doc78", "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-vnet-demo/providers/Microsoft.Network/virtualNetworks/vnet-doc78", "location": "westeurope", "addressSpace": { "addressPrefixes": ["10.0.0.0/16"] }, "provisioningState": "Succeeded", ... }}Get the VNet details:
az network vnet show \ --name vnet-doc78 \ --resource-group rg-vnet-demo{ "name": "vnet-doc78", "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-vnet-demo/providers/Microsoft.Network/virtualNetworks/vnet-doc78", "location": "westeurope", "addressSpace": { "addressPrefixes": ["10.0.0.0/16"] }, "provisioningState": "Succeeded", ...}Create and manage subnets
Section titled “Create and manage subnets”Create a subnet:
az network vnet subnet create \ --name subnet1 \ --resource-group rg-vnet-demo \ --vnet-name vnet-doc78 \ --address-prefixes 10.0.1.0/24{ "name": "subnet1", "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-vnet-demo/providers/Microsoft.Network/virtualNetworks/vnet-doc78/subnets/subnet1", "addressPrefix": "10.0.1.0/24", "provisioningState": "Succeeded", ...}Get and list subnets:
az network vnet subnet show \ --name subnet1 \ --resource-group rg-vnet-demo \ --vnet-name vnet-doc78
az network vnet subnet list \ --resource-group rg-vnet-demo \ --vnet-name vnet-doc78{ "name": "subnet1", "addressPrefix": "10.0.1.0/24", ...}[ { "name": "subnet1", "addressPrefix": "10.0.1.0/24", ... }]Create a second subnet, delete the first subnet, and list again:
az network vnet subnet create \ --name subnet2 \ --resource-group rg-vnet-demo \ --vnet-name vnet-doc78 \ --address-prefixes 10.0.2.0/24
az network vnet subnet delete \ --name subnet1 \ --resource-group rg-vnet-demo \ --vnet-name vnet-doc78
az network vnet subnet list \ --resource-group rg-vnet-demo \ --vnet-name vnet-doc78{ "name": "subnet2", "addressPrefix": "10.0.2.0/24", ...}[ { "name": "subnet2", "addressPrefix": "10.0.2.0/24", ... }]Update virtual network properties
Section titled “Update virtual network properties”Update DNS servers and tags on the VNet:
az network vnet update \ --name vnet-doc78 \ --resource-group rg-vnet-demo \ --dns-servers 8.8.8.8 8.8.4.4 \ --set tags.environment=test tags.project=localstack{ "name": "vnet-doc78", "dhcpOptions": { "dnsServers": ["8.8.8.8", "8.8.4.4"] }, "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-vnet-demo/providers/Microsoft.Network/virtualNetworks/vnet-doc78", "provisioningState": "Succeeded", "tags": { "environment": "test", "project": "localstack" }, ...}Delete and verify
Section titled “Delete and verify”Delete the VNet and verify the list is empty:
az network vnet delete \ --name vnet-doc78 \ --resource-group rg-vnet-demo
az network vnet list --resource-group rg-vnet-demo[]API Coverage
Section titled “API Coverage”| Operation ▲ | Implemented ▼ |
|---|