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

automatisation-de-votre-application-azure-13-638

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”.

1) Define the infrastructure

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.

pic1

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.

pic2

 

Here we’ll setup a simple website.

pic3

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.

pic4

2) Deploy your infrastructure

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

pic5

Click on Deploy.

Once completed you should see your Azure website listed in the portal.

3) Publish your app to your website

Now you can publish your web app through Visual Studio to the Web App you created in Step1.

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

pic6

Select your web app.

pic7

Click, “OK” and then “Publish”.

Once completed you should see your browser should open showing your freshly published website.

 

 

Leave a Reply