This example creates a virtual network with two subnets. First, a new resource group is created in
the centralus region. Then, the example creates in-memory representations of two subnets. The
New-AzVirtualNetworkSubnetConfig cmdlet will not create any subnet on the server side. There
is one subnet called frontendSubnet and one subnet called backendSubnet. The
New-AzVirtualNetwork cmdlet then creates a virtual network using the CIDR 10.0.0.0/16 as the
address prefix and two subnets.
Example 2: Create a virtual network with DNS settings
This example create a virtual network with two subnets and two DNS servers. The effect of
specifying the DNS servers on the virtual network is that the NICs/VMs that are deployed into this
virtual network inherit these DNS servers as defaults. These defaults can be overwritten per NIC
through a NIC-level setting. If no DNS servers are specified on a VNET and no DNS servers on the
NICs, then the default Azure DNS servers are used for DNS resolution.
Example 3: Create a virtual network with a subnet referencing a network security group
This example creates a virtual network with subnets that reference a network security group. First,
the example creates a resource group as a container for the resources that will be created. Then, a
network security group is created that allows inbound RDP access, but otherwise enforces the
default network security group rules. The New-AzVirtualNetworkSubnetConfig cmdlet then creates
in-memory representations of two subnets that both reference the network security group that was
created. The New-AzVirtualNetwork command then creates the virtual network.
Example 4: Create a virtual network with an IPAM Pool to auto allocate from for address prefixes
This example creates a virtual network with an IPAM (IP Address Management) pool to automatically allocate address prefixes.
First, an IPAM pool named testIpamPool is created in the testRG resource group and testNM network manager in the centralus region with the address prefix 10.0.0.0/16.
The Get-AzNetworkManagerIpamPool cmdlet retrieves the IPAM pool that was just created.
Next, a custom object representing the IPAM pool prefix allocation is created. This object includes the Id of the IPAM pool and the NumberOfIpAddresses to allocate.
The New-AzVirtualNetworkSubnetConfig cmdlet creates a subnet named testSubnet configured to use the IPAM pool prefix allocation object.
Finally, the New-AzVirtualNetwork cmdlet creates a virtual network named testVnet in the testRG resource group and centralus location.
The virtual network includes the subnet created in the previous step and uses the IPAM pool prefix allocation for address prefix allocation.
Parameters
-AddressPrefix
Specifies a range of IP addresses for a virtual network.
Indicates if encryption is enabled on the virtual network. The value should be true to enable encryption on the virtual network, false to disable encryption.
Set the Encryption EnforcementPolicy. The value should be allowUnencrypted to allow VMs without encryption capability inside an encrypted virtual network, or dropUnencrypted to disable any VM without encryption capability from being added into an encrypted virtual network.
FlowTimeout enables connection tracking for intra-VM flows. The value should be between 4 and 30 minutes (inclusive) to enable tracking, or null to disable tracking.
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.