Web UI looks good and pretty but if you really want to get work done at scale, manage, automate and administer: command line is your way. As a command line junkie from the UNIX world I thought of exploring what Azure PowerShell had to offer. And boy, I was quite blown by the ease of use, functionality and flexibility it comes with. Through this tutorial series, I will take you through various scenarios and functionality on Azure that is made easy using Azure Power Shell
Till now, I have covered the following services in Azure and how we use Power Shell to manage those:
In this post, I will cover some of the basic concepts in Azure Virtual Network and how it can be managed using PowerShell. Virtual Network is an important design element for your environment. Right from setting up your network, to implementing subnets, virtual machines and cloud services within your network, this post will get you started to have your network setup.
Creating the VNET
The way to create a VNET in Azure can be accomplished through the management portal or the preview portal or using PowerShell. When using Powershell, we need to have a xml .netcfg file that can be used to add the requisite configuration for the virtual network. One way to get a format of the xml template is to import it from your Azure Subscription if you already have a vnet created.
The XML .netcfg file may look something like this. (Note: I have created a very basic network in my subscription and hence most of the network elements are missing)
Now this file can be modified as per your configuration. However, a more holistic detail of the VNET configuration schema can be found here. Configure a virtual network using the network configuration file details this process further.
Once we have this network configuration file, we can use the Set-AzureVNetConfig to create our virtual network:
On the same lines we can also modify the configuration of the network.
Adding a Virtual Machine to your network
There are a couple of ways that a virtual machine can be added to a network. During creation time, the VNET may be specified for the virtual machine. Once a VNET is fixed for a cloud service, all the VMs in the cloud service are assigned the same VNET. The 2 ways to create VNETS using PowerShell are by using the NewAzureQuickVM and New-AzureVM cmdlet as shown below:
In case of cloud services, once the cloud service is created, you will have to add the VirtualNetworkSite element in the NetworkConfiguration element of the .csfg file of the cloud service before deploying it.
Configure Internal Load Balancer
When creating virtual machines in a virtual network, it is sometimes important to have a load balanced set of the virtual machines. Using powershell it can be done during the creation process of the virtual machines. The process is as shown below:
In this section, I basically covered how do we get started with creating a Virtual network using PowerShell. I have not covered some of the more key and important concepts of Hybrid and Multi site network such as Site-Site and Point-Site and virtual network to virtual network. I will cover these key topics and such important concepts in the following post. Stay tuned!