Portal
- In an Internet browser, go to the Azure portal. Log in using your Azure account. If you don't have an Azure account, you can sign up for a free trial.
- Click Create a resource in the portal.
- Enter Virtual network in the Search the Marketplace box at the top of the New pane that appears. Click Virtual network when it appears in the search results.
- Select Classic in the Select a deployment model box in the Virtual Network pane that appears, then click Create.
- Enter the following values on the Create virtual network (classic) pane and then click Create:If you're new to Azure, learn more about resource groups, subscriptions, and locations (also referred to as regions).
- In the portal, you can create only one subnet when you create a virtual network. In this tutorial, you create a second subnet after you create the virtual network. You might later create Internet-accessible resources in the Public subnet. You also might create resources that aren't accessible from the Internet in the Private subnet. To create the second subnet, enter myVnetin the Search resources box at the top of the page. Click myVnet when it appears in the search results.
- Click Subnets (in the SETTINGS section) on the Create virtual network (classic) pane that appears.
- Click +Add on the myVnet - Subnets pane that appears.
- Enter Private for Name on the Add subnet pane. Enter 10.0.1.0/24 for Address range. Click OK.
- On the myVnet - Subnets pane, you can see the Public and Private subnets that you created.
- Optional: When you finish this tutorial, you might want to delete the resources that you created, so that you don't incur usage charges:
- Click Overview on the myVnet pane.
- Click the Delete icon on the myVnet pane.
- To confirm the deletion, click Yes in the Delete virtual network box.
Azure CLI
- You can either install and configure the Azure CLI, or use the CLI within the Azure Cloud Shell. The Azure Cloud Shell is a free Bash shell that you can run directly within the Azure portal. It has the Azure CLI preinstalled and configured to use with your account. To get help for CLI commands, type
azure <command> --help
. - In a CLI session, log in to Azure with the command that follows. If you click Try it in the box below, a Cloud Shell opens. You can log in to your Azure subscription, without entering the following command:Azure CLI
azure login
- To ensure the CLI is in Service Management mode, enter the following command:Azure CLI
azure config mode asm
- Create a virtual network with a private subnet:Azure CLI
azure network vnet create --vnet myVnet --address-space 10.0.0.0 --cidr 16 --subnet-name Private --subnet-start-ip 10.0.0.0 --subnet-cidr 24 --location "East US"
- Create a public subnet within the virtual network:Azure CLI
azure network vnet subnet create --name Public --vnet-name myVnet --address-prefix 10.0.1.0/24
- Review the virtual network and subnets:Azure CLI
azure network vnet show --vnet myVnet
- Optional: You might want to delete the resources that you created when you finish this tutorial, so that you don't incur usage charges:Azure CLI
azure network vnet delete --vnet myVnet --quiet
Note
Though you can't specify a resource group to create a virtual network (classic) in using the CLI, Azure creates the virtual network in a resource group named Default-Networking.
PowerShell
- Install the latest version of the PowerShell Azure module. If you're new to Azure PowerShell, see Azure PowerShell overview.
- Start a PowerShell session.
- In PowerShell, log in to Azure by entering the
Add-AzureAccount
command. - Change the following path and filename, as appropriate, then export your existing network configuration file:PowerShell:-
Get-AzureVNetConfig -ExportToFile c:\azure\NetworkConfig.xml
- To create a virtual network with public and private subnets, use any text editor to add the VirtualNetworkSite element that follows to the network configuration file.XML
<VirtualNetworkSite name="myVnet" Location="East US"> <AddressSpace> <AddressPrefix>10.0.0.0/16</AddressPrefix> </AddressSpace> <Subnets> <Subnet name="Private"> <AddressPrefix>10.0.0.0/24</AddressPrefix> </Subnet> <Subnet name="Public"> <AddressPrefix>10.0.1.0/24</AddressPrefix> </Subnet> </Subnets> </VirtualNetworkSite>
Review the full network configuration file schema. - Import the network configuration file:PowerShell:-
Set-AzureVNetConfig -ConfigurationPath c:\azure\NetworkConfig.xml
Warning:-Importing a changed network configuration file can cause changes to existing virtual networks (classic) in your subscription. Ensure you only add the previous virtual network and that you don't change or remove any existing virtual networks from your subscription. - Review the virtual network and subnets:PowerShell:-
Get-AzureVNetSite -VNetName "myVnet"
- Optional: You might want to delete the resources that you created when you finish this tutorial, so that you don't incur usage charges. To delete the virtual network, complete steps 4-6 again, this time removing the VirtualNetworkSite element you added in step 5.
Note:-
Though you can't specify a resource group to create a virtual network (classic) in using PowerShell, Azure creates the virtual network in a resource group named Default-Networking.
No comments:
Post a Comment