In this video, Sharon demonstrates how to create an Azure virtual network, including adding a subnet and configuring an IP address ranges using PowerShell.
- [Narrator] We've seen how to create a virtual network using the portal, now let's do it via PowerShell. I have already launched PowerShell ISE in administrative mode, and I have already logged into my Azure account. Now let's go ahead and start creating our virtual network. The first thing I'm going to do is actually create a resource group to do so, I'm using the command New-AzureRmResourceGroup. One of the reasons I like working in ISE, is that the commands are provided for me. As I start typing a command, the commands that match it come up in a list for me.
Next we're going to provide a name, I'm going to call this ABCCompany. Nothing fancy. Then I have to provide a location. I going to put this in the EastUS. I'll go ahead and run that command. Apparently I already have a resource group called ABCCompany. So what I'm going to do is I'm going to click no, and I'm just going to modify this a little bit. It's called XYZCompany. There we go. This is one of the reasons I actually like working in ISE as well, as I build my script I can then save it. I'm going to go ahead and clear my screen. Next we need to build a virtual network into this resource group.
We're going to go ahead and use the command New-AzureRmVirtualNetwork. Where am I adding this new virtual network? Into my resource group, which I called XYZCompany. Now I need to provide a name for my virtual network, I'm just going to call it CompanyVnet, nothing fancy. And then I need to add my address space. Referred to as AddressPrefix. And finally my location. I'm going to go ahead and run that command.
We do have a warning here, don't freak out, it's okay. One of our cmdlets will be modified in a future release. It's just a warning. There we go, perfect. You can see from our output that our virtual network has been created with the address space that we specified. Next I'm going to use a variable. And this variable will contain the resource group name and the virtual network name. My variable is vnet. I'm going to use the cmdlet or command Get-AzureRmVirtualNetwork. There we go.
And now I'm going to go ahead and provide the resource group name, which is XYZCompany. And then my vnet name. These two values will be stored in our variable vnet. Finally, I'm going to go ahead and add in a subnet. To do that I'm going to use Add-AzureRmVirtualNetworkSubnetConfig. Again, I don't want to type everything, I'm just going to use the dropdown menus as they're available to me. The name, I going to call this testdev.
Now I need to provide the information about my virtual network. This is where I'm going to use my parameter. And now I need to add the address prefix. What this is going to do is rename that default subnet to testdev and we're using the entire address space. I'm going to go ahead and run that command. Then we can see that it has succeeded. Now keep in mind, at this point you're probably thinking okay, it's already created. I'm actually going to show you something. You'll see we have our resource group here, our XYZCompany.
We have our CompanyVnet. But if I looked in here and clicked in subnets, you'll see nothing is there. Even though I've entered everything through PowerShell, it has not been applied as of yet. What we need to do is run one final command within PowerShell. And that last command or cmdlet is Set-AzureRmVirtualNetwork. Provide the virtual network information, which we do have saved in that variable. And then go ahead and run this final command, there we go.
We can now see that our virtual network and our subnet has been created, and let's pop back into Azure to verify that. And there is our subnet, testdev, with our IP address range. It is totally up to you if you want to create your virtual networks in PowerShell or if you would like to do it through the portal. If you're going to be making more than one, you're probably going to want to start scripting them out, and then just running them off through PowerShell. Make your life a little bit easier.
- Creating an Azure virtual network
- Creating a virtual network using PowerShell
- Deploying a VM into a virtual network
- Modifying IP addresses
- Working with Azure DNS
- Configuring NSGs
- Setting up load balancers
- Configuring Azure load balancers
- Creating an application gateway
- Setting up on-premises connectivity
- Adding gateway VPNs
- Validating VPN devices
- Configuring VNet
- Creating site connections