Monthly Archives: October 2015

Setting up continuous deployment for a Web app on Azure with a Visual Studio Online build

 

In this post I’ll create a continuous integration build with Visual Studio Online that deploys a Web App on an Azure Website.

Inside your VSO project click on the Build menu.

Click on plus sign and choose Visual Studio.

step1

 

Here we’ll configure our build to  produce and save the Web Deploy Package package file inside the staging directory.  This package will be used to deploy our Web App inside an Azure WebSite.

Copy paste the  following MSBuild arguments into the MSBuild Arguments:
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=”$(build.stagingDirectory)”

step2

Now we’ll add a “Azure Web App Deployment” step.  Click “Add, build step” and choose in the category “Deploy” => “Azure Web Site Deployment”, click “Add”

step3

If you don’t have a Subscription configured click on: manage

step4

Click on: Configure service endpoint

step5

Choose certificate and click on publishsettings xml file

step55

Once your settings downloaded, open the file with notepad and copy the: Subscription id, Subscription name and certificate.

step6

Click OK.

Go back to the Azure build and click on refresh.

step7

Provide the “Web App Name” of your Azure Web App.

Choose your region.

Under “Web Deploy Package” you need to provide the path of your Web Deploy Package .This relates to the package location provided as an MSBuild argument in your build step (see here above).  As we published the package under the staging directory and because the package is a zip file, the following search path will do the work:
$(build.stagingDirectory)\**\*.zip

step8

Click on Save and provide a name for your new build.

You can now test your build by right-clicking on it and choose “queue build”.

step9

step10

If you want your build to become a continuous deployment build (runs at every check-in or after some time after the check-in): Edit you build definition and look for Triggers:

step11

 

 

 

 

 

 

 

 

 

 

 

 

Automate infrastructure setup through Azure Resource Group Deployment from your Visual Studio Online build

In this post I demonstrate how you can create and update your Azure infrastructure as part of a build in Visual Studio Online (VSO).  This enable to deliver and test your code and your infrastructure continuously.

Under your VSO project, choose build, and right click your build and choose “edit”, add an Azure Resource Group Deployment.

step1

To be able to provision the infrastructure from your VSO build your Resource Group Deployment need to have the permission to add or modify resources in your Azure subscription.  Therefore you can use a Service Principal that has the proper access rights in your subscription.  This msdn article details how you can create a service principal and use it during your deployment.

Watch out: if you’ve several subscriptions, chances are that you run under the wrong subscription, this will result in the following error: “The provided information does not map to an AD object id”.  You’ll need to select the proper subscription, just after the step: “Add Azure Account” use the following command:
Select-AzureSubscription -SubscriptionId <subscription-id>

The remaining steps are obvious:

step2

 

Select your Azure Subscription, provide a name to your resource group, select the ARM template inside your VS solution and the parameter file you want to use for this deployment.

Now you can include this step inside your continuous integration build or create a specific build for your infrastructure setup that you can trigger at will.

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.

 

 

How-to create a build with Visual Studio Online

This is the first in a series of How-to’s dedicated to continuous deployment with Azure.

Here I explain how to automate a simple build through visual studio online.
Before you start you should have at least one Visual Studio solution into the repository..

  1. Connect to your Visual Studio online project.
  2. Select Build, click + sign in the left column.
  3. Choose Visual Studio build as your build template

builds

  1. Click on the Save button and provide a name and description for your build definition
  2. Test your first build by queuing a new build, right-click your build step and choose queue new build

buildAgent

  1. During the build you can follows all the steps through the console inside the page.