Asp.Net RC2 WebApp with WebJob and VSTS Automation

So you want to deploy your web app and web job(s) together in Azure? Are you looking for the upgrade of my earlier post? This post is here to make it easier for you. It works for Visual Studio Team Services (VSTS).

Step 1: Restore NuGet packages

For this step, use a simple command line task.
Tool: dotnet
Arguments: restore

Step 2: Build all the projects

For this step use a Visual Studio build task. You only need to set the BuildConfiguration to x86 or x64 or Any Cpu or to the environment variable $(BuildConfiguration) since the rest are normally already set before you do it.

Step 3: Build and publish the webApp

Use a simple command line task. Assuming that the web app is named MyWebApp, set the following fields:
Tool: dotnet
Arguments: publish -c $(BuildConfiguration) -o $(Build.ArtifactStagingDirectory)\webApp
Working Folder: src/MyWebApp

Step 4: Build and publish the webJob

Use a simple command line task. Assuming that the web job is named MyWebJob, set the following fields:
Tool: dotnet
Arguments: publish -c $(BuildConfiguration) -o $(Build.ArtifactStagingDirectory)\webApp\App_Data\jobs\continuous\webJob
Working Folder: src/MyWebJob

Step 5: Zip the artifacts

When using VSTS release definitions, it is normally easy to use a Website deployment task which normally takes a zip file. Therefore, we need to zip the artifacts. Note, after Step 4 the output, has the right structure for housing the web app and the web job in azure.

This task is not provided by default in VSTS, we use the Trackyon Advantage extension which you can install into your account. Set the provided fields to:
Folder to zip: $(Build.ArtifactStagingDirectory)\webApp
Path to final Zip file: $(Build.ArtifactStagingDirectory)\website.zip

Step 6: Upload the artifacts

For this step use a Copy Publish Artifact task with the following fields:
Copy Root: $(Build.ArtifactStagingDirectory)
Contents: **/*.zip
Artifact Name: drop
Arifact Type: Server

Results

The build step should be as simple as in the image below.
build steps

Deployment

This applies to the release management feature of VSTS. Once you link the build artifacts to your release definition, add an Azure Web App Deployment task. The only sensitive variable being the Web Deploy Package. I used $(System.DefaultWorkingDirectory)\**\*.zip and it worked.