Skip to content

Commit ab825f6

Browse files
authored
add Azure Virtual Network service doc (#465)
1 parent be57a7f commit ab825f6

1 file changed

Lines changed: 276 additions & 0 deletions

File tree

Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
---
2+
title: "Virtual Network"
3+
description: Get started with Azure Virtual Network on LocalStack
4+
template: doc
5+
---
6+
7+
import AzureFeatureCoverage from "../../../../components/feature-coverage/AzureFeatureCoverage";
8+
9+
## Introduction
10+
11+
Azure Virtual Network (VNet) is the core networking service for isolating and routing Azure resources in private IP address spaces.
12+
It lets you define address ranges, create subnets, and control network behavior for applications.
13+
Virtual networks are commonly used to model secure, segmented network topologies in cloud environments. For more information, see [What is Azure Virtual Network?](https://learn.microsoft.com/en-us/azure/virtual-network/virtual-networks-overview).
14+
15+
LocalStack for Azure provides a local environment to build and test Azure networking resources, such as virtual networks, private endpoints, and private DNS zones.
16+
The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of Virtual Network's integration with LocalStack.
17+
18+
## Getting started
19+
20+
This guide is designed for users new to Virtual Network and assumes basic knowledge of the Azure CLI and our `azlocal` wrapper script.
21+
22+
Launch LocalStack using your preferred method. For more information, see [Introduction to LocalStack for Azure](/azure/getting-started/). Once the container is running, enable Azure CLI interception by running:
23+
24+
```bash
25+
azlocal start-interception
26+
```
27+
28+
This command points the `az` CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator API.
29+
30+
To revert this configuration, run:
31+
32+
```bash
33+
azlocal stop-interception
34+
```
35+
36+
This reconfigures the `az` CLI to send commands to the official Azure management REST API.
37+
38+
### Create a resource group
39+
40+
Create a resource group for your networking resources:
41+
42+
```bash
43+
az group create \
44+
--name rg-vnet-demo \
45+
--location westeurope
46+
```
47+
48+
```bash title="Output"
49+
{
50+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-vnet-demo",
51+
"location": "westeurope",
52+
"managedBy": null,
53+
"name": "rg-vnet-demo",
54+
"properties": {
55+
"provisioningState": "Succeeded"
56+
},
57+
...
58+
}
59+
```
60+
61+
### Create and inspect a virtual network
62+
63+
Create a virtual network with a `10.0.0.0/16` address space:
64+
65+
```bash
66+
az network vnet create \
67+
--name vnet-doc78 \
68+
--resource-group rg-vnet-demo \
69+
--location westeurope \
70+
--address-prefixes 10.0.0.0/16
71+
```
72+
73+
```bash title="Output"
74+
{
75+
"newVNet": {
76+
"name": "vnet-doc78",
77+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-vnet-demo/providers/Microsoft.Network/virtualNetworks/vnet-doc78",
78+
"location": "westeurope",
79+
"addressSpace": {
80+
"addressPrefixes": ["10.0.0.0/16"]
81+
},
82+
"provisioningState": "Succeeded",
83+
...
84+
}
85+
}
86+
```
87+
88+
Get the virtual network (VNet) details:
89+
90+
```bash
91+
az network vnet show \
92+
--name vnet-doc78 \
93+
--resource-group rg-vnet-demo
94+
```
95+
96+
```bash title="Output"
97+
{
98+
"name": "vnet-doc78",
99+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-vnet-demo/providers/Microsoft.Network/virtualNetworks/vnet-doc78",
100+
"location": "westeurope",
101+
"addressSpace": {
102+
"addressPrefixes": ["10.0.0.0/16"]
103+
},
104+
"provisioningState": "Succeeded",
105+
...
106+
}
107+
```
108+
109+
### Create and manage subnets
110+
111+
Create a subnet:
112+
113+
```bash
114+
az network vnet subnet create \
115+
--name subnet1 \
116+
--resource-group rg-vnet-demo \
117+
--vnet-name vnet-doc78 \
118+
--address-prefixes 10.0.1.0/24
119+
```
120+
121+
```bash title="Output"
122+
{
123+
"name": "subnet1",
124+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-vnet-demo/providers/Microsoft.Network/virtualNetworks/vnet-doc78/subnets/subnet1",
125+
"addressPrefix": "10.0.1.0/24",
126+
"provisioningState": "Succeeded",
127+
...
128+
}
129+
```
130+
131+
Retrieve new subnet details and list all VNet subnets
132+
133+
```bash
134+
az network vnet subnet show \
135+
--name subnet1 \
136+
--resource-group rg-vnet-demo \
137+
--vnet-name vnet-doc78
138+
139+
az network vnet subnet list \
140+
--resource-group rg-vnet-demo \
141+
--vnet-name vnet-doc78
142+
```
143+
144+
```bash title="Output"
145+
{
146+
"name": "subnet1",
147+
"addressPrefix": "10.0.1.0/24",
148+
...
149+
}
150+
[
151+
{
152+
"name": "subnet1",
153+
"addressPrefix": "10.0.1.0/24",
154+
...
155+
}
156+
]
157+
```
158+
159+
Add a second subnet to the virtual network, remove the first , and relist all subnets:
160+
161+
```bash
162+
az network vnet subnet create \
163+
--name subnet2 \
164+
--resource-group rg-vnet-demo \
165+
--vnet-name vnet-doc78 \
166+
--address-prefixes 10.0.2.0/24
167+
168+
az network vnet subnet delete \
169+
--name subnet1 \
170+
--resource-group rg-vnet-demo \
171+
--vnet-name vnet-doc78
172+
173+
az network vnet subnet list \
174+
--resource-group rg-vnet-demo \
175+
--vnet-name vnet-doc78
176+
```
177+
178+
```bash title="Output"
179+
{
180+
"name": "subnet2",
181+
"addressPrefix": "10.0.2.0/24",
182+
...
183+
}
184+
[
185+
{
186+
"name": "subnet2",
187+
"addressPrefix": "10.0.2.0/24",
188+
...
189+
}
190+
]
191+
```
192+
193+
### Update virtual network properties
194+
195+
Update DNS servers and tags on the VNet:
196+
197+
```bash
198+
az network vnet update \
199+
--name vnet-doc78 \
200+
--resource-group rg-vnet-demo \
201+
--dns-servers 8.8.8.8 8.8.4.4 \
202+
--set tags.environment=test tags.project=localstack
203+
```
204+
205+
```bash title="Output"
206+
{
207+
"name": "vnet-doc78",
208+
"dhcpOptions": {
209+
"dnsServers": ["8.8.8.8", "8.8.4.4"]
210+
},
211+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-vnet-demo/providers/Microsoft.Network/virtualNetworks/vnet-doc78",
212+
"provisioningState": "Succeeded",
213+
"tags": {
214+
"environment": "test",
215+
"project": "localstack"
216+
},
217+
...
218+
}
219+
```
220+
221+
### Delete and verify
222+
223+
Delete the VNet and validate that no virtual networks remain in the resource group:
224+
225+
```bash
226+
az network vnet delete \
227+
--name vnet-doc78 \
228+
--resource-group rg-vnet-demo
229+
230+
az network vnet list --resource-group rg-vnet-demo
231+
```
232+
233+
```bash title="Output"
234+
[]
235+
```
236+
237+
## Features
238+
239+
The Virtual Network emulator supports the following features:
240+
241+
- **Virtual networks**: Create, update, delete, list, and get virtual networks with configurable address spaces, DNS servers, and DDoS protection settings.
242+
- **Subnets**: Full lifecycle management of subnets within virtual networks, including address prefix allocation, service endpoint configuration, and NSG/route table associations.
243+
- **Network security groups**: Create and manage network security groups with custom security rules. Default rules (AllowVnetInBound, AllowAzureLoadBalancerInBound, DenyAllInBound, AllowVnetOutBound, AllowInternetOutBound, DenyAllOutBound) are automatically provisioned.
244+
- **Route tables**: Create and manage route tables with custom route entries supporting next hop types such as VirtualAppliance, VirtualNetworkGateway, Internet, and VnetLocal.
245+
- **Public IP addresses**: Create and manage public IP addresses with Static or Dynamic allocation methods, Standard or Basic SKUs, and availability zone configuration.
246+
- **Public IP prefixes**: Create and manage public IP prefixes with configurable prefix lengths and SKU settings.
247+
- **NAT gateways**: Create and manage NAT gateways with public IP address and public IP prefix associations.
248+
- **Network interfaces**: Create and manage network interfaces with IP configurations, dynamic IP allocation from subnets, accelerated networking, and IP forwarding settings.
249+
- **Private DNS zones**: Create and manage private DNS zones with virtual network links, registration enablement, and A record sets.
250+
- **Private endpoints**: Create and manage private endpoints with automatic network interface provisioning, private link service connections, and private DNS zone group integration.
251+
- **Bastion hosts**: Create and manage bastion hosts with IP configuration validation, SKU selection (Basic, Standard, Premium), and scale unit configuration.
252+
253+
## Limitations
254+
255+
- **No network traffic routing**: The emulator does not route network traffic or enforce security rules. Resources are stored and returned with correct metadata, but no packet-level behavior is applied.
256+
- **IPv6**: IPv6 fields are accepted in requests but are not functional. All IP allocation operates on IPv4 address spaces only.
257+
- **Private DNS record types**: Only A record sets are supported in private DNS zones. Other record types (CNAME, MX, TXT, SRV, AAAA) are not available.
258+
- **Public IP addresses**: Addresses are locally generated and do not represent routable IPs on the public internet.
259+
- **Bastion host connectivity**: Feature flags such as tunneling, file copy, and Kerberos authentication are stored as configuration but do not provide actual connectivity.
260+
- **VNet peering**: Virtual network peering is not supported.
261+
- **VPN and ExpressRoute gateways**: VPN gateways and ExpressRoute circuits are not implemented.
262+
- **Load balancers**: Azure Load Balancer resources are not implemented.
263+
- **Application gateways**: Application Gateway resources are not implemented.
264+
- **Network watchers**: Network Watcher and flow log resources are not implemented.
265+
- **No data persistence**: Network resources are not persisted and are lost when the emulator is stopped or restarted.
266+
267+
## Samples
268+
269+
The following samples demonstrate how to use Virtual Network with LocalStack for Azure:
270+
271+
- [Function App and Service Bus](https://github.com/localstack/localstack-azure-samples/tree/main/samples/function-app-service-bus/dotnet/)
272+
- [Web App and Cosmos DB for MongoDB API](https://github.com/localstack/localstack-azure-samples/tree/main/samples/web-app-cosmosdb-mongodb-api/python/)
273+
274+
## API Coverage
275+
276+
<AzureFeatureCoverage service="Microsoft.Network" client:load />

0 commit comments

Comments
 (0)