Question

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?

Was it helpful?

Solution

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

The old website solution should be prepared a bit:

  1. Set up Storage and Cloud Service at your Azure account;
  2. Install Azure SDK and if needed Powershell Azure Cmdlets (before Azure SDK 2.0 they were not integrated into the SDK);
  3. Add new project to the solution with the type Cloud -> Azure Project, but don't select roles on this step;
  4. 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.

OTHER TIPS

It's absolutely possible. If using Azure Websites, you can do a git-deploy, dropbox, etc. If Cloud Services (web role), you can build via visual studio (IDE or command line), then deploy the package with PowerShell.

EDIT Quick example using PowerShell, to create a cloud service locally (via New-AzureServiceProject and [Add-AzureWebRole(http://msdn.microsoft.com/en-us/library/windowsazure/dn205203.aspx)):

New-AzureServiceProject -ServiceName myservice
Add-AzureWebRole -Name MyWebRole

You can add your code to the created web role and use msbuild to build it (and cspack to package it). You can then deploy your built package with PowerShell, via New-AzureDeployment:

New-AzureDeployment -ServiceName "mynewservice" -Slot "production -Package packagepath -Configuration configpath -Label "my service deployment"

Note that with the package and configuration paths, they can either be local or in a blob (and you'd need to upload them to blobs before calling New-AzureDeployment). Also look at Publish-AzureServiceProject.

Note: The Azure PowerShell cmdlet reference is here. But... if you type get-help *azure* at the PS command line, you'll see the latest cmdlets, and you can then look at help for individual cmdlets).

Beyond that, I'm not sure exactly what you're looking for. But I strongly suggest spending some time with the command-line tools + documentation, as well as running through a few basic tutorials on asp.net + Azure, such as this one for Web Sites and this one for Cloud Services (in particular, the intro video).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top