Содержание
Use the vnet-n-subnet building block template to deploy an Azure virtual network (VNet). This building block deploys a virtual network with no additional resources. To deploy a VNet with that includes Network Security Groups (NSGs) or User Defined Routes (UDRs), use the following building blocks:
Parameters
There is one parameter in this building block template named virtualNetworkSettings. It contains the following properties:
- name
Value. Required.
Name of the VNet. - addressPrefixes
Array of values. Required.
Specifies the CIDR address blocks for the entire VNet. Supports multiple CIDR prefixes. - subnets
Array of objects. Required.
Specifies the subnets within the VNet. Subnets are specified by the following object:- name
Value. Required.
Name of the subnet. - addressPrefix
Value. Required.
CIDR address block for the subnet (must be valid within the VNet address space definition).
- name
- dnsServers
Array of values. Optional.
Specifies one or more custom DNS Server address for the VNet. Leave the array empty to use Azure internal name resolution.
Deployment
You can deploy a building block template using Azure portal, PowerShell, or Azure CLI.
Azure portal
Note that deploying via Azure Portal requires your parameter file to have a publicly available URI.
- Right-click the button below and select either "open link in new tab" or "open link in new window":
- Wait for the Azure Portal to open.
- In the
Basics
section:
- Select your
Subscription
from the drop-down list. - For the
Resource group
, you can either create a new resource group or use an existing resource group. - Select the region where you'd like to deploy the VNet in the
Location
drop-down list.
- In the
Settings
section, enter a URI to a valid parameter file. There are several example parameter files in Github. Note that if you want to use one of these parameter files the URI must be the path to theraw
file in Github. - Review the terms and conditions, then click the I agree to the terms and conditions stated above checkbox.
- Click the Purchase button.
- Wait for the deployment to complete.
PowerShell
To deploy the building block template using a parameter file hosted at a publicly available URI, follow these steps:
- Upload your parameter file to a location with a publicly available URI.
- Log in to Azure using your selected subscription:
Login-AzureRmAccount -SubscriptionId <your subscription ID>
- If you do not have an existing resource group, run the New-AzureRmResourceGroup cmdlet to create one as shown below:
New-AzureRmResourceGroup -Location <Target Azure Region> -Name <Resource Group Name>
- Run the New-AzureRmResourceGroupDeployment cmdlet as shown below:
New-AzureRmResourceGroupDeployment -ResourceGroupName <Resource Group Name> -TemplateUri https://raw.githubusercontent.com/mspnp/template-building-blocks/v1.0.0/scenarios/vnet-n-subnet/azuredeploy.json -templateParameterUriFromTemplate <URI of parameter file>
Example
The cmdlet below creates a resource group named app1-rg in the westus region, then deploys the vnet-multiple-subnet-dns parameter file from the scenarios folder in Github.
Login-AzureRmAccount -SubscriptionId <your subscription ID>
New-AzureRmResourceGroup -Location westus -Name app1-rg
New-AzureRmResourceGroupDeployment -ResourceGroupName app1-rg -TemplateUri https://raw.githubusercontent.com/mspnp/template-building-blocks/v1.0.0/scenarios/vnet-n-subnet/azuredeploy.json -templateParameterUriFromTemplate https://raw.githubusercontent.com/mspnp/template-building-blocks/v1.0.0/scenarios/vnet-n-subnet/parameters/vnet-multiple-subnet-dns.parameters.json
Azure CLI
Before you begin, install the latest version of the Azure CLI.
To deploy the building block template using a parameter file hosted at a publicly available URI, follow these steps:
- Upload your parameter file to a location with a publicly available URI.
- Log in to Azure using your selected subscripton:
az login
- Set your selected subscription:
az account set --subscription <your subscripton ID>
- If you do not have an existing resource group, create a new one using the following command:
az group create -l <Target Azure Region> -n <Resource Group Name>
- Run the command below to deploy the VNet:
az group deployment create -g <Resource Group Name> --template-uri https://raw.githubusercontent.com/mspnp/template-building-blocks/v1.0.0/scenarios/vnet-n-subnet/azuredeploy.json --parameters "{\"templateParameterUri\":{\"value\":\"<parameter file public URI>\"}}"
Example
The command below creates a resource group named app1-rg in the westus region, then deploys the vnet-multiple-subnet-dns parameter file from the scenarios folder in Github.
az login
az group create -l "westus" -n "app1-rg"
az group deployment create -g app1-rg --template-uri https://raw.githubusercontent.com/mspnp/template-building-blocks/v1.0.0/scenarios/vnet-n-subnet/azuredeploy.json --parameters "{\"templateParameterUri\":{\"value\":\"https://raw.githubusercontent.com/mspnp/template-building-blocks/v1.0.0/scenarios/vnet-n-subnet/parameters/vnet-multiple-subnet-dns.parameters.json\"}}"
- Introduction
- Version 1
- Version 2
- Overview
- How To
- Install Template Building Blocks version 2 (Windows)
- Install Template Building Blocks version 2 (Linux)
- Use Template Building Blocks version 2 Command Line
- Create a Template Building Blocks Parameter File
- Specify and override default subscription ID, resource group, or location
- Secure the files used by the Template Building Block command line tool
- Reference