With the emergence of Windows Azure, Cloud Construct has decided to migrate its existing site to a web role to run in the Azure cloud. We will be utilizing a hosted service, App Storage, and SQL Azure. Our existing site runs as a .NET 4.0 just-in-time compiled website, hosted on IIS, and with a SQL backend. This post will deal with migrating the existing .NET 4.0 site to run in the Azure service host environment, following posts will deal with connecting to SQL Azure.
You will notice that a new Windows Azure Cloud Service project will be added to your new solution. Secondly. a Web Role project will be added which is similar to a web application project but includes a WebRole.cs file which defines the web role entry point. This WebRole application will be assigned to your cloud service project and will be started up when your service starts up. The WebRole project will be included with some default files such as a Scripts directory and some basic .NET web pages. I deleted all of these boilerplate resources so could begin porting my site into this project.
Right now the easiest way to migrate your site into the project is to simply copy all the files over. Do not overwrite the web.config file! Any settings you had in there prior you can then cut-n-paste them into the WebRole project web.config. After you have copied all your files over, there are a few steps you will have to perform. If you are coming from a web application project then you will not have to perform these next step two steps.
Because the WebRole project is technically a web application project you must convert your just-in-time compiled web pages to web application pages. This basically means adding a *designer.cs file to every page. The easiest way to do this is right click on the project in solution explorer and choose "Convert to Web Application". This will add designer files to all web page files.
Because a web application project does not include an App_Code directory you must move all class files to a separate class library project. You will end up with multiple assembly conflicts if you do not which will cause a whole bunch of other problems.
Now that you have all your content ported over you can rebuild your new solution and make sure everything is all good. Lastly, start debugging the project and make sure your website runs in the local dev environment. If it all comes up the first time then your in luck. You might have to tweak some other portions of your site to make sure it all works but for the most part this should get you there. One snag I hit was documents being served out of the site like PDF's will require you to set their build action to "Content" instead of "None". This will make sure the file gets packaged and deployed with your cloud service.
About the Author:
Arra Derderian serves as the President and as a Lead Technical Architect for Cloud Construct. As a founder at Cloud Construct, Arra is involved in all levels of the business from new project engagements, project planning, and development.
He also serves as the founder of the Boston Orchard CMS User Group and is a member of the Windows Azure Insiders group.
Arra graduated from Northeastern University School with a Bachelor of Science degree in Computer Science.