HowTo: migrate an established WebApp to Azure

 

image1109The Windows Azure platform exists for a long time till now but I never had the chance to migrate an established Web application to Azure. I try to document this step by step. The first step is really easy: build a WebApp package and enter SQLAzure (the easiest way).

 

 

"deferral" – my scenario

The base of this blogpost is an ASP.NET MVC 2 application which is using an SQL server as data bank. Any kind of windows services, Services Bus Stuff or other constructs are not part of this. I just want my WebApp to run under Azure with an instance in the simplest case. That´s not a big thing but a first step Zwinkerndes Smiley

What do I need?

Of course you need the latest version of Windows Azure SDK (I´m use the June 2010 Version – is this the latest? Zwinkerndes Smiley ) Also you need an SQL Management Studio Express and if you installed a bigger SQL Server on your computer than you might read this.

Demo Solution

imageWe have a standard MVC App without any references to azure assemblies. Therefore we have our file bank on the SQL Server. But I´m going to talk about the SQL Server later.

Add a Cloud Project

After the installation of the windows azure SDKs you will find a new project type:

image

In the following window it´s possible to create a new project but in our case we already have a WebApp.

image

So just click on "ok".

Now add the existing project

With the context menu you are able to add an existing web application as web role

image

image

 

Debugging

Now you can start the MVC Project but also the cloud project. At the cloud project the application will be hosted on the local Cloud-Dev-Plattform:

image

Adapt the config – DiagnosticsConnectionString

For the logs in the local environment a config entry will be created in the cloud config. This one have to be deleted before the Deployment.

My ServiceConfiguration.cscfg

<?xml version="1.0"?>
<ServiceConfiguration serviceName="MoveToAzure.WebHost" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
  <Role name="MoveToAzure.WebApp">
    <Instances count="1" />
    <ConfigurationSettings />
  </Role>
</ServiceConfiguration>

My ServiceDefinition.csdef

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="MoveToAzure.WebHost" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
  <WebRole name="MoveToAzure.WebApp">
    <InputEndpoints>
      <InputEndpoint name="HttpIn" protocol="http" port="80" />
    </InputEndpoints>
    <ConfigurationSettings />
  </WebRole>
</ServiceDefinition>

Both "ConfigurationSettings" are empty. Otherwise our project won´t run in the Cloud.

MVC adaption

At the moment the cloud doesn´t know the MVC2 DLL and because of this we need to define "Copy Local":

image

Cloud – publish…

Those of you who are using an SQL file base and want to change to SQL Azure should read the second part first because after deployment you won´t be able to access the web.config. Here you need to apply the WebApp a little to reach thinks like this a little bit easier.

But we are going on with the easier case "without DB":

With the context menu of the cloud-project we are able to build a package:

image

IMPORTANT: the configuration of the build act should be on release.

Go one to the right code

imageCreate a new server on http://windows.azure.com.

Now chose a "Hosted Service." The imageother alternative is just disk space for tables, queues and blobs. At this point this is not interesting for us.

In this screen you choose a name and eventually a description for the imageservice.

At this point you need to be careful. If you start slowly than you need to beware that, for example, the SQLAzure Instance is situated in the same region like the WebApp. At least you choose a domain for the service.

 

image

After this you enter a site with the actual state of the staging environment:image

Click on Deploy and after this choose the already builded package file and upload it:

image

After the upload you need to click on "run". Now it will take a few minutes until Microsoft saved the WebApp.

After the click on "Run":

imageNow the instance will start. This procedure will take 5 or 10 minutes. First there will be the init phase after this a short busy phase will start and then the icon will change into green for "Ready". Now it works. If you did not make the changes like I told you before the WebApp won´t start and will be "Busy" for a long time before it stops. No pretty error message Trauriges Smiley

 

 

Because of this I wrote this HowTo Zwinkerndes Smiley

SQL Azure

If you use a MS SQL data base you will be able to have a SQL Azure data base. Here the connectionString is shown and you can use it for example in the SQL Management Studio and connect to the data base. For safety reasons you need to enter you IP address.

Probably there are many ways to transfer files from A to B. I´ve generated a SQL Script and these two parameter are very useful with that:

image

You will find this dialog if you enter a SQL DB, click right on "Tasks" "Generate Scripts."

Afterwards you pass the SQL to the SQL Azure via Management Studio and that´s it. Smiley mit geöffnetem Mund

Now the apply the ConnectionString in the WebApp and see if it works Zwinkerndes Smiley

Result

For now the WebApp with DB should run on Azure. But there are several problems to solve like for example how to use the Session ore the Cache with Azure and build a scalable Application. But for now this will work Zwinkerndes Smiley

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

About the author

Written by Code Inside Team

Learn more about our team.

One Response

  1. I thought fdining this would be so arduous but it’s a breeze!

    Reply

Comment on this post

Recent Posts

  • Automated Security Analyser for ASP.NET websites

    Evil Hackers are lurking everywhere and many Web-applications are delicately and share “too much” with the attacker. A quick (first!) overview offers the Tool “ASafaWeb”. All the website does is making a few requests and writing an Analyses including problem solving’s. There are no permanent disadvantages (bad requests/ DoS attacks and so on). Example: KnowYourStack.com ...

  • image1489-570x194.png
    „Sign in with Twitter“ for your own ASP.NET WebApp

      “Sign in with Twitter” is a popular practice to authenticate the users on your website. One advantage compared to an own registration is the lower inhibition for the user. But on the other hand Twitter doesn’t fess up with all the information’s and you will get into a kind of addiction. At the end ...

  • image1485-570x194_thumb.png
    CodePlex is going to be updated

      CodePlex the Microsoft Open Source Project Hosting Plattform hasn’t changed that much in the last few years and for a few times I thought Microsoft stopped the whole developing process. But now I found out that there is still life in the project. Maybe it is because of the success of GitHub or because ...

  • image1474_thumb.png
    What does Adobe in the flash-free web? Magazine-Style Layouts with CSS Regions!

      Adobe is well known for Photoshop and Flash but of course there is a lot more. According to the “Future Post” from Google Adobe declared one of their big subjects on a Blogpost. I’m talking about the W3C Working Draft to CSS Regions. Adobe cooperates with the WebKit Team and W3C on this. What ...

  • image1471-523x194.png
    HTML 5 Games, Tooling & 3D

      Game Developing is an interesting subject for all kind of software developer. But as a web developer without any Flash-skills there aren’t that much starting points. With HTML5 and the combination between Javascript, CSS3 and fast browsers there are the first “robust” HTML5 games. HTML5 games? Is this real? Neowin created a “Top 10” ...

Support us