Home > other >  Configure the virtual network using the network configuration file
Configure the virtual network using the network configuration file

Time:09-21

In Azure command line interface (CLI) 1.0 or Azure PowerShell is used in the network configuration file is used to create and configure the virtual network (classic), and not be able to use the network configuration file by Azure Resource Manager deployment model to create or modify a virtual network, can't use in Azure portal network configuration file to create or modify a virtual network (classic), but it can be directly in the Azure portal to create a virtual network (classic), without having to use the network configuration file,

Using the network configuration files to create and configure virtual network (classic) need to export, change and import the file,

export network configuration file
Can use the PowerShell or Azure CLI export network configuration file, PowerShell export XML files, and Azure CLI export json file,

PowerShell
1. Install the Azure PowerShell and log in to the Azure,
2. In the following command (and make sure it exists) according to the need to change the directory and file name, and then run the command to export the network configuration file:
 Get AzureVNetConfig - ExportToFile c: \ azure \ networkconfig XML 


Azure CLI 1.0
1. Install the Azure CLI 1.0 by 1.0 Azure CLI command prompt to complete the remaining steps,
2. Enter the azure login - e AzureChinaCloud command login to azure,
3. Enter the azure config mode asm command to ensure that in the asm model,
4. In the following command according to the need to change the directory (and make sure it exists) and the name of the file, then run the command to export the network configuration file:
 azure network export c: \ azure \ networkconfig json 


Create or modify the network configuration file
Network configuration file is an XML file (when using the PowerShell) or a json file (using Azure CLI), can be in any text or XML/json editor to edit the file, the network configuration file setting the set provides all the details of the article, more instructions about the Settings, please refer to the view and setting up the virtual network, the changes on the document:
Must conform to the architecture, or import the network configuration file will fail,
Covered the existing network of subscription Settings, so please take care all the more when modified, for example, please refer to the following example network configuration file, assuming that the original file contains two VirtualNetworkSite instance, and we have changes according to the example shown in this document, the import file, the Azure will delete in the file we delete VirtualNetworkSite virtual network as an example, this simplified solution assuming no resources in the virtual network, if any, will not delete virtual network, and import will fail,

sample XML for PowerShell
The following example network configuration files in the "east China" create named myVirtualNetwork Azure area, address space for the virtual network 10.0.0.0/16, which contains a virtual network, called mySubnet address prefix for 10.0.0.0/24 subnet,
 & lt; ? The XML version="1.0" encoding="utf-8"?> 



10.0.0.0/16 & lt;/AddressPrefix>


10.0.0.0/24 & lt;/AddressPrefix>






If the network configuration file does not contain any content of export, then you can copy the example above the XML, and paste it into the new file,

example JSON for Azure CLI 1.0
The following example network configuration files in the "east China" create named myVirtualNetwork Azure area, address space for the virtual network 10.0.0.0/16, which contains a virtual network, called mySubnet address prefix for 10.0.0.0/24 subnet,
 {
"VirtualNetworkConfiguration" : {
"Dns" : ", "
"VirtualNetworkSites" : [
{
"AddressSpace" : [" 10.0.0.0/16 "],
"Location" : "China East,"
"Name" : "myVirtualNetwork,"
"Subnets" : [
{
"AddressPrefix" : "10.0.0.0/24,"
"Name" : "mySubnet
"}
]
}
]
}
}

If the network configuration file does not contain any content of export, then you can copy the example of json, and paste it into the new file,

import network configuration file

Can use the PowerShell or Azure CLI network configuration file to import, PowerShell XML file to import, and Azure CLI json file to import, if the import fails, please make sure the file is in line with the network configuration architecture,

PowerShell
1. Install the Azure PowerShell and log in to the Azure,
2. According to the need to change the directory and file names in the following command, and then run the command into the network configuration file
 Set - AzureVNetConfig - ConfigurationPath c: \ azure \ networkconfig XML 


Azure CLI 1.0
1. Install the Azure CLI 1.0 by 1.0 Azure CLI command prompt to complete the remaining steps,
2. Enter the azure login - e AzureChinaCloud command login to azure,
3. Enter the azure config mode asm command to ensure that in the asm model,
4. According to the need to change the directory and file names in the following command, and then run the command into the network configuration file:
 azure network import c: \ azure \ networkconfig json 


More operating method, can the reference here,
  • Related