Script to create a VPN Site-to-Site using Azure Resource Manager

Share this:

The process to create a VPN Site-to-Site in Microsoft Azure requires a series of cmdlets, and at this time the administrator cannot use Azure Preview Portal for that purpose.


We created the VPN site-to-site using Azure Resource Manager on this Tutorial and we used the following diagram to help understanding the concepts behind of all cmdlets involved in the process.



After creating that Tutorial, we decided to create a simple script to automate the process, and we called it AZFast-VPN-s2s.ps1 and it can be download from here.

Defining the variables…

During the process, some items are repeated several times and since it is not a task that most of administrators do every week, then we have some room for mistakes. In our script we are grouping the settings at the begging of the script and the administrator just need to fill out the information. We divided in two sections: Azure and On-Premises, as shown in the figure below.

The script below contains the same information of the diagram, this way you can use that to compare and change based on your environment.


Running the script..

The first step is connect on Microsoft Azure using Microsoft Azure PowerShell, and we explain the process on this following Tutorial: and after that the script can be run by just typing its name .\AZFastVPN-s2s.ps1 as shown in the image below.


The process will take a while, and at the end we will provide the information that you can copy and paste in an e-mail to your administrator containing three key pieces of information to complete the setup which are: Shared Key, Azure VPN IP and some examples how to configure your existent firewall.


Please feel free to change the script to fit your requirements. If you find a better way to automate, please drop us a comment.

Written by Anderson Patricio

Anderson Patricio is a Canadian Exchange Server MVP and MCSM (Solutions Master) and he contributes to the Microsoft Community with articles, tutorials, blog posts, forums and book reviews. He is a regular contributor at, and (Portuguese).