Warning: session_start() [function.session-start]: open(C:\Windows\SERVIC~2\NETWOR~1\AppData\Local\Temp\\sess_a211df1f81009c1806e7717beaa42e58, O_RDWR) failed: Permission denied (13) in E:\hshome\snagy\azure.snagy.name\blog\wp-content\plugins\si-captcha-for-wordpress\si-captcha.php on line 763

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at E:\hshome\snagy\azure.snagy.name\blog\wp-content\plugins\si-captcha-for-wordpress\si-captcha.php:763) in E:\hshome\snagy\azure.snagy.name\blog\wp-content\plugins\si-captcha-for-wordpress\si-captcha.php on line 763

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at E:\hshome\snagy\azure.snagy.name\blog\wp-content\plugins\si-captcha-for-wordpress\si-captcha.php:763) in E:\hshome\snagy\azure.snagy.name\blog\wp-content\plugins\si-captcha-for-wordpress\si-captcha.php on line 763
Above The Cloud » Blog Archive » Converting A Web App Into An Azure Cloud Service Web Role


 12 May 2009 @ 8:05 AM 
 

Converting A Web App Into An Azure Cloud Service Web Role

 

I’ve recently been working on a little side project – a site called “azure101.com”. I originally created it as a web application project and now decided I wanted to show some friends. I thought about hosting it on a beta sub domain (i.e. beta.azure101.com) but then it occurred to me that I should put it on Azure instead. This meant I needed to create a cloud service project and affiliate my web app with it.

This is a pretty easy thing to achieve if your app stands alone and doesn’t use any databases, etc (which is definitely the case here) so I thought I’d share the few simple steps needed to achieve this.

First you need to add a cloud service project to your solution. In the ‘Add New Project’ dialog, ensure you select the ‘Blank Cloud Service’ option:

image

image

This adds the cloud service to your solution – I named mine ‘azure101CloudService’. You will notice only the one project is added to your solution and that the ‘Roles’ node is empty. We need to affiliate our existing web app to the cloud service as a ‘Web Role’. But when we right click the node we don’t get the option to add an existing web project in our solution – its disabled.

This is because the cloud service project does not yet recognize our web application as a valid cloud web role. To fix this we need to make a change to the project file directly.

 

 

image

 

Editing a project file is not as scary as it sounds. All project files in Visual Studio are built on MSBuild and are friendly looking XML files that follow a specific schema. If you’re familiar with NAnt then you’ll be able to pickup MSBuild in no time, however in our case the change is very simple and you don’t need knowledge of MSBuild to make this change.

First we need to unload our web application project file, and then edit it. I have certain power tools installed that let me unload and edit in one click – “Edit Project File”. If you don’t have this option, simply choose the “Unload” option and then the “Edit” option. It should be pretty obvious where to click. You will notice that when unloaded you will not be able to see any of the files in your project. This is perfectly normal.

In the project file you will see a bunch of XML and we’re looking for a node that’s called ‘PropertyGroup’ (there will be more than 1, just use the first one in the file). This essentially is a list of variables that the build script will use. We are going to add a new variable (property) called ‘RoleType’. As the last element in the PropertyGroup, add this code:

<RoleType>Web</RoleType>

imageThis extra property is what marks a project as being a web role for a cloud service. Save your change and close the file. You can now right click on your web project and reload it. This should restore it to its original state. You can still use the project exactly as before – run it by itself to see what I mean.

Now we can attempt to affiliate the web project with our cloud service. Go back to the Roles node and right click again. This time you can see that the option to add a ‘Web Role Project in solution’ is available. When selected, we then get presented with a dialog where we can choose which project to add – our web application is an option. We select it and when all is done, our web app now appears as a role in our project. imageimage

 

 

 

 

 

 

 

 

 

So there you go! Quick and easy. The important thing now is that you can either run the web app standalone, or you can run it on your local development fabric, OR you can deploy it to Windows Azure.

Tags Tags: , , ,
Categories: Azure
Posted By: Steven Nagy
Last Edit: 12 May 2009 @ 08 05 AM

E-mailPermalink
 

Responses to this post » (4 Total)

 
  1. Above The Cloud » Blog Archive » Windows Azure Development Deep Dive: Working With Configuration said...
    10:26 pm - March 7th, 2010

    [...] applications, configuration can work exactly the same as standard .Net applications. If you have a web role, then you have a web.config. And if you have a worker role, you get an app.config. This allows you [...]

  2. Alex said...
    7:30 pm - January 20th, 2012

    Thanks for this tip, really helped me with bringing my existing Windows Service into the Azure Worker Role project. Cool looking site, by the way!

  3. Luella said...
    7:01 am - February 18th, 2013

    Luella…

    Above The Cloud » Blog Archive » Converting A Web App Into An Azure Cloud Service Web Role…

  4. go here said...
    3:46 pm - May 4th, 2013

    go here…

    Above The Cloud » Blog Archive » Converting A Web App Into An Azure Cloud Service Web Role…

 

Leave A Comment ...

 

 XHTML:
You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
\/ More Options ...
Change Theme...
  • Users » 25016
  • Posts/Pages » 64
  • Comments » 191
Change Theme...
  • VoidVoid
  • LifeLife
  • EarthEarth
  • WindWind « Default
  • WaterWater
  • FireFire
  • LiteLight
  • No Child Pages.

Warning: Unknown(): open(C:\Windows\SERVIC~2\NETWOR~1\AppData\Local\Temp\\sess_a211df1f81009c1806e7717beaa42e58, O_RDWR) failed: Permission denied (13) in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0