How to create Azure Networks via CLI

Learn how to create an Azure Networks via the Command Line Interface

Posted: December 7, 2016
Tags: Azure  CLI 
Share this on

The following is the CLI process you can use to create Azure network Resources:

  1. Download the Windows CLI http://aka.ms/webpi-azure-cli
  2. From a command prompt
azure config mode arm
azure login

Once your environment is configured then you can create the network bits:

C:\Users\Steven>azure group create -n "CLITestGroup" -l "East US"
info:    Executing command group create
+ Getting resource group CLITestGroup
+ Updating resource group CLITestGroup
info:    Updated resource group CLITestGroup
data:    Id:                  /subscriptions/####/resourceGroups/CLITestGroup
data:    Name:                CLITestGroup
data:    Location:            eastus
data:    Provisioning State:  Succeeded
data:    Tags: null
data:
info:    group create command OK

C:\Users\Steven>azure group show -n "CLITestGroup"
info:    Executing command group show
+ Getting resource group
+ Listing resources for the group
data:    Id:                  /subscriptions/####/resourceGroups/CLITestGroup
data:    Name:                CLITestGroup
data:    Location:            eastus
data:    Provisioning State:  Succeeded
data:    Tags: null
data:    Resources:  []
data:    Permissions:
data:      Actions: *
data:      NotActions:
data:
info:    group show command OK

C:\Users\Steven>azure network vnet create -g "CLITestGroup" -n "TestVNET" -l "East US"
info:    Executing command network vnet create
warn:    Using default address prefix: 10.0.0.0/8
+ Looking up the virtual network "TestVNET"
+ Creating virtual network "TestVNET"
data:    Id                              : /subscriptions/####/resourceGroups/CLITestGroup/providers/Microsoft.Network/virtualNetworks/TestVNET
data:    Name                            : TestVNET
data:    Type                            : Microsoft.Network/virtualNetworks
data:    Location                        : eastus
data:    Provisioning state              : Succeeded
data:    Address prefixes:
data:      10.0.0.0/8
info:    network vnet create command OK

C:\Users\Steven>azure network vnet subnet create -g "CLITestGroup" --vnet-name "TestVNET" -n "TestSubnet" --address-prefix 10.0.1.0/24
info:    Executing command network vnet subnet create
+ Looking up the virtual network "TestVNET"
+ Looking up the subnet "TestSubnet"
+ Creating subnet "TestSubnet"
data:    Id                              : /subscriptions/####/resourceGroups/CLITestGroup/providers/Microsoft.Network/virtualNetworks/TestVNET/subnets/TestSubnet
data:    Name                            : TestSubnet
data:    Provisioning state              : Succeeded
data:    Address prefix                  : 10.0.1.0/24
info:    network vnet subnet create command OK

C:\Users\Steven>azure network public-ip create -g "CLITestGroup" -n "TestPIP" -l "East US" --allocation-method "Dynamic"
info:    Executing command network public-ip create
warn:    Using default --idle-timeout 4
warn:    Using default --ip-version IPv4
+ Looking up the public ip "TestPIP"
+ Creating public ip address "TestPIP"
data:    Id                              : /subscriptions/####/resourceGroups/CLITestGroup/providers/Microsoft.Network/publicIPAddresses/TestPIP
data:    Name                            : TestPIP
data:    Type                            : Microsoft.Network/publicIPAddresses
data:    Location                        : eastus
data:    Provisioning state              : Succeeded
data:    Allocation method               : Dynamic
data:    IP version                      : IPv4
data:    Idle timeout in minutes         : 4
info:    network public-ip create command OK

C:\Users\Steven>azure network public-ip set -g "CLITestGroup" -n "TestPIP" --domain-name-label "sfdemo"
info:    Executing command network public-ip set
+ Looking up the public ip "TestPIP"
+ Updating public ip address "TestPIP"
data:    Id                              : /subscriptions/####/resourceGroups/CLITestGroup/providers/Microsoft.Network/publicIPAddresses/TestPIP
data:    Name                            : TestPIP
data:    Type                            : Microsoft.Network/publicIPAddresses
data:    Location                        : eastus
data:    Provisioning state              : Succeeded
data:    Allocation method               : Dynamic
data:    IP version                      : IPv4
data:    Idle timeout in minutes         : 4
data:    Domain name label               : sfdemo
data:    FQDN                            : sfdemo.eastus.cloudapp.azure.com
info:    network public-ip set command OK

C:\Users\Steven>azure network nic create -g "CLITestGroup" -l "East US" -n "TestNIC" --subnet-name "TestSubnet" --subnet-vnet-name "TestVNET" --public-ip-name "TestPIP"
info:    Executing command network nic create
+ Looking up the network interface "TestNIC"
+ Looking up the subnet "TestSubnet"
+ Looking up the public ip "TestPIP"
+ Creating network interface "TestNIC"
data:    Id                              : /subscriptions/####/resourceGroups/CLITestGroup/providers/Microsoft.Network/networkInterfaces/TestNIC
data:    Name                            : TestNIC
data:    Type                            : Microsoft.Network/networkInterfaces
data:    Location                        : eastus
data:    Provisioning state              : Succeeded
data:    Internal domain name suffix     : 4jp02gpvxk3unmgym2ggxgi0ec.bx.internal.cloudapp.net
data:    Enable IP forwarding            : false
data:    IP configurations:
data:      Name                          : default-ip-config
data:      Primary                       : true
data:      Provisioning state            : Succeeded
data:      Private IP address            : 10.0.1.4
data:      Private IP version            : IPv4
data:      Private IP allocation method  : Dynamic
data:      Public IP address             : /subscriptions/####/resourceGroups/CLITestGroup/providers/Microsoft.Network/publicIPAddresses/TestPIP
data:      Subnet                        : /subscriptions/####/resourceGroups/CLITestGroup/providers/Microsoft.Network/virtualNetworks/TestVNET/subnets/TestSubnet
data:
info:    network nic create command OK

In a future post we’ll create a VM and bind to the network in a future post

Posted: December 7, 2016
Tags: Azure  CLI 
Share this on

I love delivering IoT solutions

Read more about what I do and our philosophy. Judge for yourself the work and results achieved for other clients.

Contact Me

back to top