How to deploy to Azure Cloud Service

.net, asp.net, azure, azure-cloud-services, deployment

Solution

After some time of researching, I've found a working solution.

The old website solution should be prepared a bit:

- Set up Storage and Cloud Service at your Azure account;

- Install Azure SDK and if needed Powershell Azure Cmdlets (before Azure SDK 2.0 they were not integrated into the SDK);

- Add new project to the solution with the type `Cloud -> Azure Project`, but don't select roles on this step;

- Right-click on roles and add from existing web project.

At this step you may deploy solution from Visual Studio's drop-down menus like "Publish..." or "Package...". But configure your role first.

To make the package be automatically deployed, just do the script, which is described here. This is the most clean script, I've found, which is making Deployment procedure of any Azure SDK.

To make automatic project package, just run the following powershell script:

$project = resolve-path ".\..\relative\path\to\azure\deploy\project.ccproj"
Import-Module -Name ".\Invoke-MsBuild.psm1"
$buildSucceeded = Invoke-MsBuild -Path $project -P '/p:configuration=release /p:overwritereadonlyfiles=true /p:targetprofile="Cloud" /target:Clean;Publish'
if ($buildSucceeded)
{ Write-Host "Build completed successfully." }
else
{ Write-Host "Build failed. Check the build log file for errors." }

For this script, you will need Invoke-MsBuild.

Problem

The default tutorials of Azure explains how to create a project from scratch, and deploy it to Azure Cloud Service. I have got into unexpectable problem while trying to deploy existed project. So, what I have is existed web solution of several projects stored in GIT. Inside solution there is a main project, which contains all relations and after building the folder of this project is ready for deployment to server. The question is - how can I configure the project for Azure Deployment, and build a deployment package for it through the CLI tools?

Original source