How To: Use Azure Resource Manager in Visual Studio for creating Web Apps

Here we want to create our Azure Web App from within visual studio.  The goal is to be able to recreate the infrastructure at will and host a web app on it.  We do this by including an Azure Resource Group project inside our solution. This bundle the code of our website with the definition of the infrastructure that is needed to host the website. The Azure Resource Group project contains the description of your infrastructure inside an ARM(Azure Resource Manager) template and one or many parameter files. With this project you make sure that your configurations can be consistently repeated, tested, shared and promoted across different environments. This concept is called “infrastructure as code”.

First we need to add an Azure Resource Group project to our visual studio solution.

Right-click Add, new project.

If you didn’t have downloaded the Azure SDK, you first need to install it.

Choose “Get Microsoft Azure SDK for .Net” from the Cloud category and complete the installation steps.

Once the Azure SDK installed, reload your solution, right click on your solution, add, new project and select Cloud, “Azure Resource Group”, provide a name to your project and click OK.

Here we’ll setup a simple website.

 

Then we’ll need to fill in the parameters.  You can do this via the deploy wizard or directly inside the “Website.param.dev.json” file. The file is located under your ARM project in the folder Templates.

The siteName and hostingPlanName are up to you, you can fill in what you like or provide the name of an existing one.  For siteLocation you’ve to choose between one of the Azure datacenter regions, you find the list under: https://azure.microsoft.com/en-gb/regions/

Just Copy the name of the region that is appropriate to you.

 

Right click your ARM project and choose Deploy, New Deployment.

 Click on Deploy

 

Once completed you should see the newly created website in the portal.

 

Now you can publish your web app through Visual Studio.

Right Click your web project, choose publish and select “Microsoft Azure Web App”.

Add comment