|
| 1 | +--- |
| 2 | +title: 'Quickstart: Deploy IPAM pools and static CIDRs with Azure Virtual Network Manager - Bicep' |
| 3 | +description: In this quickstart, you learn how to deploy Azure Virtual Network Manager with IPAM pools and static CIDR allocations using Bicep templates. |
| 4 | +author: mbender-ms |
| 5 | +ms.author: mbender |
| 6 | +ms.service: azure-virtual-network-manager |
| 7 | +ms.topic: quickstart |
| 8 | +ms.date: 06/20/2025 |
| 9 | +ms.custom: |
| 10 | + - template-quickstart |
| 11 | + - mode-arm |
| 12 | + - devx-track-bicep |
| 13 | + - devx-track-azurepowershell |
| 14 | + - devx-track-azurecli |
| 15 | +--- |
| 16 | + |
| 17 | +# Quickstart: Deploy IPAM pools and static CIDRs with Azure Virtual Network Manager - Bicep |
| 18 | + |
| 19 | +Learn how to deploy Azure Virtual Network Manager with IP Address Management (IPAM) pools and static CIDR allocations using Bicep templates. Azure Virtual Network Manager simplifies IP address planning by providing centralized management and automatic allocation of non-overlapping address spaces. |
| 20 | + |
| 21 | +[!INCLUDE [virtual-network-manager-ipam](../../includes/virtual-network-manager-ipam.md)] |
| 22 | + |
| 23 | +In this quickstart, you: |
| 24 | + |
| 25 | +- Deploy an Azure Virtual Network Manager instance |
| 26 | +- Create an IPAM pool with specified address space |
| 27 | +- Allocate a static CIDR block within the pool |
| 28 | +- Associate existing virtual networks to IPAM pools |
| 29 | +- Create new virtual networks using IPAM pool allocations |
| 30 | + |
| 31 | +## Prerequisites |
| 32 | + |
| 33 | +- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). |
| 34 | +- Azure CLI or Azure PowerShell installed locally, or use [Azure Cloud Shell](https://shell.azure.com). |
| 35 | + |
| 36 | +## Review the Bicep file |
| 37 | + |
| 38 | +The following Bicep template creates an Azure Virtual Network Manager instance with an IPAM pool and static CIDR allocation. The template defines these Azure resources: |
| 39 | + |
| 40 | +- [**Microsoft.Network/networkManagers**](/azure/templates/microsoft.network/networkmanagers): Creates an Azure Virtual Network Manager instance |
| 41 | +- [**Microsoft.Network/networkManagers/ipamPools**](/azure/templates/microsoft.network/networkmanagers/ipampools): Creates an IPAM pool under the network manager |
| 42 | +- [**Microsoft.Network/networkManagers/ipamPools/staticCidrs**](/azure/templates/microsoft.network/networkmanagers/ipampools/staticcidrs): Creates a static CIDR allocation in the IPAM pool |
| 43 | + |
| 44 | +```bicep |
| 45 | +@description('Location for resources.') |
| 46 | +param locationName string = resourceGroup().location |
| 47 | +
|
| 48 | +@description('Name of the Virtual Network Manager') |
| 49 | +param networkManagerName string = 'vnm-learn-prod-${locationName}-001' |
| 50 | +
|
| 51 | +@description('Name of the IPAM pool') |
| 52 | +param ipamPoolName string = 'ipam-pool-learn-prod-001' |
| 53 | +
|
| 54 | +@description('Address prefix of the IPAM pool') |
| 55 | +param ipamPoolAddressPrefix string = '10.0.0.0/16' |
| 56 | +
|
| 57 | +@description('Name of the static CIDR') |
| 58 | +param staticCidrName string = 'static-cidr-reserved-001' |
| 59 | +
|
| 60 | +@description('Address prefix of the static CIDR') |
| 61 | +param staticCidrAddressPrefix string = '10.0.1.0/24' |
| 62 | +
|
| 63 | +// Virtual Network Manager |
| 64 | +resource networkManager 'Microsoft.Network/networkManagers@2024-05-01' = { |
| 65 | + name: networkManagerName |
| 66 | + location: locationName |
| 67 | + properties: { |
| 68 | + networkManagerScopes: { |
| 69 | + managementGroups: [] |
| 70 | + subscriptions: [ |
| 71 | + subscription().id |
| 72 | + ] |
| 73 | + } |
| 74 | + networkManagerScopeAccesses: [ |
| 75 | + 'Connectivity' |
| 76 | + ] |
| 77 | + } |
| 78 | +} |
| 79 | +
|
| 80 | +// IPAM Pool |
| 81 | +resource ipamPool 'Microsoft.Network/networkManagers/ipamPools@2024-05-01' = { |
| 82 | + parent: networkManager |
| 83 | + name: ipamPoolName |
| 84 | + location: locationName |
| 85 | + properties: { |
| 86 | + addressPrefixes: [ |
| 87 | + ipamPoolAddressPrefix |
| 88 | + ] |
| 89 | + } |
| 90 | +} |
| 91 | +
|
| 92 | +// Static CIDR |
| 93 | +resource staticCidr 'Microsoft.Network/networkManagers/ipamPools/staticCidrs@2024-05-01' = { |
| 94 | + parent: ipamPool |
| 95 | + name: staticCidrName |
| 96 | + properties: { |
| 97 | + addressPrefixes: [ |
| 98 | + staticCidrAddressPrefix |
| 99 | + ] |
| 100 | + } |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +## Deploy the Bicep template |
| 105 | + |
| 106 | +Save the Bicep template to your local computer as **main.bicep**, then deploy it using either Azure CLI or Azure PowerShell. |
| 107 | + |
| 108 | +### [Azure CLI](#tab/azure-cli) |
| 109 | + |
| 110 | +```azurecli |
| 111 | +az group create \ |
| 112 | + --name rg-network-manager \ |
| 113 | + --location eastus2 |
| 114 | +
|
| 115 | +az deployment group create \ |
| 116 | + --resource-group rg-network-manager \ |
| 117 | + --template-file main.bicep |
| 118 | +``` |
| 119 | + |
| 120 | +### [Azure PowerShell](#tab/azure-powershell) |
| 121 | + |
| 122 | +```azurepowershell |
| 123 | +$rgParams = @{ |
| 124 | + Name = 'rg-network-manager' |
| 125 | + Location = 'eastus2' |
| 126 | +} |
| 127 | +New-AzResourceGroup @rgParams |
| 128 | +
|
| 129 | +$deploymentParams = @{ |
| 130 | + ResourceGroupName = 'rg-network-manager' |
| 131 | + TemplateFile = 'main.bicep' |
| 132 | +} |
| 133 | +New-AzResourceGroupDeployment @deploymentParams |
| 134 | +``` |
| 135 | + |
| 136 | +--- |
| 137 | + |
| 138 | +The deployment takes a few minutes to complete. When the deployment finishes, you see a message indicating that the deployment succeeded. |
| 139 | + |
| 140 | +## Associate an existing virtual network to an IPAM pool |
| 141 | + |
| 142 | +The following Bicep template associates an existing virtual network with an IPAM pool. This scenario is useful when you have existing virtual networks that you want to manage through Azure Virtual Network Manager's IPAM feature. |
| 143 | + |
| 144 | +The template defines this Azure resource: |
| 145 | + |
| 146 | +- [**Microsoft.Network/virtualNetworks**](/azure/templates/microsoft.network/virtualnetworks): Modifies an existing virtual network to associate it with the IPAM pool |
| 147 | + |
| 148 | +```bicep |
| 149 | +@description('Name of an existing virtual network') |
| 150 | +param existingVnetName string = 'vnet-existing-001' |
| 151 | +
|
| 152 | +@description('Location of an existing virtual network') |
| 153 | +param existingVnetLocation string = 'eastus2' |
| 154 | +
|
| 155 | +@description('Resource ID of an existing IPAM pool') |
| 156 | +param existingIpamPoolId string = '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-network-manager/providers/Microsoft.Network/networkManagers/vnm-learn-prod-eastus2-001/ipamPools/ipam-pool-learn-prod-001' |
| 157 | +
|
| 158 | +// Virtual Network |
| 159 | +resource existingVnet 'Microsoft.Network/virtualNetworks@2024-05-01' = { |
| 160 | + name: existingVnetName |
| 161 | + location: existingVnetLocation |
| 162 | + properties: { |
| 163 | + addressSpace: { |
| 164 | + ipamPoolPrefixAllocations: [ |
| 165 | + { |
| 166 | + pool: { |
| 167 | + id: existingIpamPoolId |
| 168 | + } |
| 169 | + } |
| 170 | + ] |
| 171 | + } |
| 172 | + } |
| 173 | +} |
| 174 | +``` |
| 175 | + |
| 176 | +### Deploy the association template |
| 177 | + |
| 178 | +1. Save the Bicep template to your local computer as **associate-existing-vnet.bicep**. |
| 179 | + |
| 180 | +2. Use a text or code editor to update the following parameters in the file: |
| 181 | + - Change `existingVnetName` to the name of your existing virtual network |
| 182 | + - Change `existingVnetLocation` to the location of your existing virtual network |
| 183 | + - Change `existingIpamPoolId` to the resource ID of your existing IPAM pool |
| 184 | + |
| 185 | +3. Save the **associate-existing-vnet.bicep** file. |
| 186 | + |
| 187 | +4. Deploy the Bicep template using either Azure CLI or Azure PowerShell. Replace `rg-existing-vnet` with the resource group name of the existing virtual network: |
| 188 | + |
| 189 | +### [Azure CLI](#tab/azure-cli-associate) |
| 190 | + |
| 191 | +```azurecli |
| 192 | +az deployment group create \ |
| 193 | + --resource-group rg-existing-vnet \ |
| 194 | + --template-file associate-existing-vnet.bicep |
| 195 | +``` |
| 196 | + |
| 197 | +### [Azure PowerShell](#tab/azure-powershell-associate) |
| 198 | + |
| 199 | +```azurepowershell |
| 200 | +$deploymentParams = @{ |
| 201 | + ResourceGroupName = 'rg-existing-vnet' |
| 202 | + TemplateFile = 'associate-existing-vnet.bicep' |
| 203 | +} |
| 204 | +New-AzResourceGroupDeployment @deploymentParams |
| 205 | +``` |
| 206 | + |
| 207 | +--- |
| 208 | + |
| 209 | +When the deployment finishes, you see a message indicating that the deployment succeeded. |
| 210 | + |
| 211 | +## Create a new virtual network using IPAM pool allocation |
| 212 | + |
| 213 | +The following Bicep template creates a new virtual network that automatically receives IP address allocation from an IPAM pool. This approach simplifies virtual network creation by ensuring non-overlapping address spaces. |
| 214 | + |
| 215 | +The template defines this Azure resource: |
| 216 | + |
| 217 | +- [**Microsoft.Network/virtualNetworks**](/azure/templates/microsoft.network/virtualnetworks): Creates an IPAM-managed virtual network |
| 218 | + |
| 219 | +```bicep |
| 220 | +@description('Name of new virtual network') |
| 221 | +param newVnetName string = 'vnet-learn-prod-001' |
| 222 | +
|
| 223 | +@description('Name of default subnet') |
| 224 | +param subnetName string = 'snet-default-001' |
| 225 | +
|
| 226 | +@description('Location for virtual network') |
| 227 | +param locationName string = resourceGroup().location |
| 228 | +
|
| 229 | +@description('Resource ID of an existing IPAM pool') |
| 230 | +param existingIpamPoolId string = '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-network-manager/providers/Microsoft.Network/networkManagers/vnm-learn-prod-eastus2-001/ipamPools/ipam-pool-learn-prod-001' |
| 231 | +
|
| 232 | +@description('Number of IP addresses for virtual network') |
| 233 | +param vnetNumberOfIpAddresses string = '256' |
| 234 | +
|
| 235 | +@description('Number of IP addresses for subnet') |
| 236 | +param subnetNumberOfIpAddresses string = '128' |
| 237 | +
|
| 238 | +// Virtual Network |
| 239 | +resource newVnet 'Microsoft.Network/virtualNetworks@2024-05-01' = { |
| 240 | + name: newVnetName |
| 241 | + location: locationName |
| 242 | + properties: { |
| 243 | + addressSpace: { |
| 244 | + ipamPoolPrefixAllocations: [ |
| 245 | + { |
| 246 | + numberOfIpAddresses: vnetNumberOfIpAddresses |
| 247 | + pool: { |
| 248 | + id: existingIpamPoolId |
| 249 | + } |
| 250 | + } |
| 251 | + ] |
| 252 | + } |
| 253 | + subnets: [ |
| 254 | + { |
| 255 | + name: subnetName |
| 256 | + properties: { |
| 257 | + ipamPoolPrefixAllocations: [ |
| 258 | + { |
| 259 | + numberOfIpAddresses: subnetNumberOfIpAddresses |
| 260 | + pool: { |
| 261 | + id: existingIpamPoolId |
| 262 | + } |
| 263 | + } |
| 264 | + ] |
| 265 | + } |
| 266 | + } |
| 267 | + ] |
| 268 | + } |
| 269 | +} |
| 270 | +``` |
| 271 | + |
| 272 | +### Deploy the new virtual network template |
| 273 | + |
| 274 | +1. Save the Bicep template to your local computer as **create-ipam-managed-vnet.bicep**. |
| 275 | + |
| 276 | +2. Use a text or code editor to update the following parameter in the file: |
| 277 | + - Change `existingIpamPoolId` to the resource ID of your existing IPAM pool |
| 278 | + |
| 279 | +3. Save the **create-ipam-managed-vnet.bicep** file. |
| 280 | + |
| 281 | +4. Deploy the Bicep template using either Azure CLI or Azure PowerShell: |
| 282 | + |
| 283 | +### [Azure CLI](#tab/azure-cli-create) |
| 284 | + |
| 285 | +```azurecli |
| 286 | +az deployment group create \ |
| 287 | + --resource-group rg-network-manager \ |
| 288 | + --template-file create-ipam-managed-vnet.bicep |
| 289 | +``` |
| 290 | + |
| 291 | +### [Azure PowerShell](#tab/azure-powershell-create) |
| 292 | + |
| 293 | +```azurepowershell |
| 294 | +$deploymentParams = @{ |
| 295 | + ResourceGroupName = 'rg-network-manager' |
| 296 | + TemplateFile = 'create-ipam-managed-vnet.bicep' |
| 297 | +} |
| 298 | +New-AzResourceGroupDeployment @deploymentParams |
| 299 | +``` |
| 300 | + |
| 301 | +--- |
| 302 | + |
| 303 | +When the deployment finishes, you see a message indicating that the deployment succeeded. |
| 304 | + |
| 305 | +## Verify the deployment |
| 306 | + |
| 307 | +After deploying the templates, verify that the IPAM pool and virtual network configurations are working correctly: |
| 308 | + |
| 309 | +1. In the [Azure portal](https://portal.azure.com), navigate to your Virtual Network Manager instance. |
| 310 | + |
| 311 | +2. Under **IP address management**, select **IP address pools**. |
| 312 | + |
| 313 | +3. Select your IPAM pool to view its allocations and usage statistics. |
| 314 | + |
| 315 | +4. Under **Settings**, select **Allocations** to see all resources associated with the pool, including static CIDR blocks and virtual networks. |
| 316 | + |
| 317 | +## Clean up resources |
| 318 | + |
| 319 | +If you no longer need the resources created in this quickstart, delete the resource group and all its contained resources: |
| 320 | + |
| 321 | +### [Azure CLI](#tab/azure-cli-cleanup) |
| 322 | + |
| 323 | +```azurecli |
| 324 | +az group delete --name rg-network-manager --yes --no-wait |
| 325 | +``` |
| 326 | + |
| 327 | +### [Azure PowerShell](#tab/azure-powershell-cleanup) |
| 328 | + |
| 329 | +```azurepowershell |
| 330 | +Remove-AzResourceGroup -Name 'rg-network-manager' -Force -AsJob |
| 331 | +``` |
| 332 | + |
| 333 | +--- |
| 334 | + |
| 335 | +## Next steps |
| 336 | + |
| 337 | +In this quickstart, you deployed Azure Virtual Network Manager with IPAM pools and learned how to associate virtual networks with IP address pools. To learn more about IP address management in Azure Virtual Network Manager: |
| 338 | + |
| 339 | +> [!div class="nextstepaction"] |
| 340 | +> [What is IP address management (IPAM) in Azure Virtual Network Manager?](concept-ip-address-management.md) |
| 341 | +
|
| 342 | +> [!div class="nextstepaction"] |
| 343 | +> [Manage IP addresses with Azure Virtual Network Manager](how-to-manage-ip-addresses-network-manager.md) |
0 commit comments