The 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
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? ) Also you need an SQL Management Studio Express and if you installed a bigger SQL Server on your computer than you might read this.
Add a Cloud Project
After the installation of the windows azure SDKs you will find a new project type:
In the following window it´s possible to create a new project but in our case we already have a WebApp.
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
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:
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.
<?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>
<?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.
At the moment the cloud doesn´t know the MVC2 DLL and because of this we need to define "Copy Local":
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:
IMPORTANT: the configuration of the build act should be on release.
Go one to the right code
Create a new server on http://windows.azure.com.
Now chose a "Hosted Service." The other 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 service.
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.
After this you enter a site with the actual state of the staging environment:
Click on Deploy and after this choose the already builded package file and upload it:
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":
Now 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 :(
Because of this I wrote this HowTo
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:
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.
Now the apply the ConnectionString in the WebApp and see if it works
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