Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Azure PowerShell – Create Virtual Network Within Resource Group

Posted on December 29, 2016 By David Kittell

This is still a work in progress to include all the variables but the script below will create a Resource Group then create a Virtual Network with 3 subnets and a gateway along with custom DNS.

# Main Reference: https://docs.microsoft.com/en-us/azure/virtual-network/virtual-networks-create-vnet-arm-ps

Clear

Write-verbose "Setting Environment Variables - Start"

$VNetName = “azuredev-eastus-vnet”
$VNetPrefix = “10.40.0.0/24”
$SubNet01Name = “AppSubnet”
$SubNet01Prefix = “10.40.0.0/25”
$SubNet02Name = “ServicesSubnet”
$SubNet02Prefix = “10.40.0.128/26”
$SubNet03Name = “DataSubnet”
$SubNet03Prefix = “10.40.0.192/27”
$GWSubName = “Gateway”
$GWSubPrefix = “10.40.0.224/29”
$VPNClientAddressPool = “172.16.201.0/24”
$RG = “azuredev-eastus-rg”
$Location = “East US”
$DNS01 = “208.67.222.222”
$DNS02 = “208.67.220.220”
$GWName = “azuredev-eastus-gw”
$GWIPName = “azuredev-eastus-gwip”
$GWIPconfName = “azuredev-eastus-gwipconf”
$P2SRootCertName = “azuredev-eastus-RootCertificate”

Write-verbose "Setting Environment Variables - Stop"

# Log into Azure Account
# Login-AzureRmAccount

# List all Azure Subscriptions
# Get-AzureSubscription | Format-Table subscriptionname, subscriptionid

#Write-Verbose "Select Azure Subscription"
#Select-AzureRmSubscription -SubscriptionId <Subscription ID> # Dev


Write-Verbose "Creating a New Azure Resource Group $RG"
New-AzureRmResourceGroup -Name $RG -Location $Location

Write-Verbose "Creating a Virtual Network $VNetName within the Resource Group $RG"
New-AzureRmVirtualNetwork -ResourceGroupName $RG -Name $VNetName -AddressPrefix $VNetPrefix -Location $Location -DnsServer $DNS01,$DNS02

$vnet = Get-AzureRmVirtualNetwork -ResourceGroupName $RG -Name $VNetName

Write-Verbose "Creating Subnet $SubNet01Name within $VNetName "
Add-AzureRmVirtualNetworkSubnetConfig -Name $SubNet01Name  -VirtualNetwork $vnet -AddressPrefix $SubNet01Prefix

Write-Verbose "Creating Subnet $SubNet02Name within $VNetName "
Add-AzureRmVirtualNetworkSubnetConfig -Name $SubNet02Name  -VirtualNetwork $vnet -AddressPrefix $SubNet02Prefix

Write-Verbose "Creating Subnet $SubNet03Name within $VNetName "
Add-AzureRmVirtualNetworkSubnetConfig -Name $SubNet03Name  -VirtualNetwork $vnet -AddressPrefix $SubNet03Prefix

Write-Verbose "Creating Subnet $GWSubName within $VNetName "
Add-AzureRmVirtualNetworkSubnetConfig -Name $GWSubName  -VirtualNetwork $vnet -AddressPrefix $GWSubPrefix

Write-Verbose "Save Changes To $VNetName in Azure"
Set-AzureRmVirtualNetwork -VirtualNetwork $vnet
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Azure Code Network

Post navigation

Previous post
Next post

Related Posts

Bash – Download YouTube Music

Posted on August 7, 2018June 30, 2019

sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl sudo chmod a+rx /usr/local/bin/youtube-dl sudo apt update sudo apt upgrade -y sudo apt install youtube-dl python ffmpeg net-tools -y # Install YouTube Downloader CLI brew install youtube-dl ffmpeg # https://github.com/rg3/youtube-dl # Download YouTube video, convert the video to MP3 and delete the original video…

Read More

Create Directory If It Doesn't Exist

Posted on September 27, 2013October 26, 2015

If File.ExternalWritable Then If File.IsDirectory(File.DirRootExternal,"new/") = False Then File.MakeDir(File.DirRootExternal, "new") sDBLocation = File.DirRootExternal & "/new" End If Else If File.IsDirectory(File.DirInternal,"new/") = False Then File.MakeDir(File.DirInternal, "new") sDBLocation = File.DirInternal & "/new" End If End If Originally Posted on September 27, 2013Last Updated on October 26, 2015 All information on this site…

Read More

Android Contacts – Remove Spaces / Line Breaks From Postal Address

Posted on February 21, 2014October 26, 2015

UPDATE data SET data1 = ltrim(ifnull(data4, ”) || ‘ ‘ || ifnull(data5, ”) || ‘ ‘ || ifnull(data6, ”) || ‘ ‘ || ifnull(data7, ”) || ‘ ‘ || ifnull(data8, ”) || ‘ ‘ || ifnull(data9, ”) || ‘ ‘ || ifnull(data10, ”)) WHERE mimetype_id IN ( SELECT _id FROM…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes