Tuesday, 15 September 2015

How to setup azure network with WebApp and Database VM and configure VPN to workstation


PS

This artcle is just example how to use GATEWAY but in real app avoid using gateway. Read more

Intro

Few weeks ago i started playing with Azure. My task was simple how to configure Asp.Net Mvc Application and connect to database which is on other server in same network. The main reason why i spend lots of time is that i was using preview portal and as i understood its not yet ready and there is still some bugs and not finished features, but generally i like what Azure team did, new design is cool and allow to customize dashboard so you can easily configure what you want to see.
I would suggest to start from configuring network

Network

Lets start our configuration from network. Click on New -> Networking -> Virtual Network -> Deployment model -> Classic
NOTE: Dont choose Resource Manager deployment type because then you will not be able to connect with WebApp

Configure Address space

Address space CIDR block: 10.0.0.0/16 
Subnet name: Db
Click create and wait. Azure will add icon to your dashboard after you hit create.

After its done network details will be opened.


Next step would be to create gateway where we will be able to connect via vpn and connect our web app. Click on gateway icon and select point to site connection type, I default address spaces since 256 addresses in range 10.1.0.0 is enough for me since i will have one web app scalable from 1 to 10 and 1 vpn connection at time.


after you hit ok it will start deployment and generally it takes up to 30 mins. so we have time to start with webapp

As soon as gateway is created root certificate should be uploaded so it will be possible to connect to this network with vpn.
Start command line as Administrator
Go to 
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\
and run command
makecert -sky exchange -r -n "CN=BetaRootCertificate" -pe -a sha1 -len 2048 -ss My "BetaRootCertificate.cer"
Upload certificate to azure by clicking on your network then -> Point to site -> Manage certificates -> Upload

After we deployed our root certificate we need to generate client certificate from same path 
makecert.exe -n "CN=ClientBeta" -pe -sky exchange -m 96 -ss My -in "BetaRootCertificate" -is my -a sha1
We are ready now to connect via vpn, on the vpn connection where manage certificate buttons there is VPN Client buttons choose which you need 32 or 64 bit. Download it and install and here we go we are ready to connect.

WebApp


To host asp.net mvc i choose web app since its easy to manage and scale. MOre info how to use you can find in the web.New-> Web + Mobile -> Web App 


To use vnet minimum requirement is Standart types. 
After Webapp is created we would need to finish configuration of network. Click on webapp and scroll to networking
Click on vnet integration, then setup in VNet integration section, then choose our existing network from list.

Database




After that wait few mins since it takes some time to create availability set. When you choose right availability set network will be configured automatically and you will not be able to change network settings for this VM

Now our web app will be able to see database server. In next post i will show problems with deploying Asp.net MVC with mysql database.

Refferences

https://social.msdn.microsoft.com/Forums/azure/en-US/87c07656-61f4-4ad7-9b6c-248b484dc1ab/pointtosite-on-windows-8-client-connection-error-798?forum=WAVirtualMachinesVirtualNetwork

https://azure.microsoft.com/en-gb/documentation/articles/vpn-gateway-point-to-site-create/#generate-a-self-signed-root-certificate

http://stackoverflow.com/questions/16320918/windows-azure-virtual-network-point-to-site-connection-error
http://www.systemsup.co.uk/azure-point-to-site-error-798/
Volodymyr Bilyachat Web Developer