Moving the application to Windows Azure
A New Project
The first step is to add a new cloud project to the solution.
Ensure that you do not add any web or worker roles.
We will convert the existing web application within the solution to a Web Role in the Azure Project.
Right Click on the ‘Roles’ folder in the Azure Project, select ‘Add’ and then ‘Web Role Project in solution…’.
Select the web application – in this case ‘SharPix_Step2’
After adding the project as a Web Role, it should look like this:
Right-Click on the ‘SharPix_Step2’ role and select ‘Properties’
In this dialog, under normal circumstances, you should set Instance count to at least 2 to enable fail-over and scaling, and you would pick an appropriate VM size.
Also, we will start by using the Compute and Storage Emulators, so specify ‘UseDevelopmentStorage=true’ as the Diagnostics storage account.
Running In Emulator…
Visual Studio comes with a tiny taste of the cloud built-in, in the form of the Storage and Compute Emulators.
Simply running our new Azure Project gives us:
Note the URL and the port number. This is no longer the Visual Studio Development Web Server, but the Compute Emulator in action. Examining the Windows Tray shows us that the emulators are running….
To the cloud!
In order to push the Azure Project to our cloud environment, we need to configure Visual Studio and set up our credentials to ensure that we carefully control access to our Azure environment.
Right-Click on the Azure Project and select ‘Publish’. We could use previously issued certificates here, or issue a new one for this project by selecting ‘Add’.
Create a New Certificate, and fill in the details required.
Visual Studio creates a new certificate and stores it in a temporary, obscure, folder. Copy the path from this dialog onto your clipboard and head over to the Windows Azure Management portal.
Click on ‘Management Certificates’, select the Azure Subscription you want to deploy to, and select ‘Add Certificate’ from the right-click context menu.
Once the certificate is uploaded, select and copy the Subscription ID from the portal and fill it into (3) of the Windows Azure Project Management Authentication dialog shown above. Give the Project some reasonable name and click ‘OK’
After dispatching all the other dialogs, you will be left with the first ‘Publish Windows Azure Application’ dialog. Ensure you have selected a Production Environment, and specify the storage account to use.
Hurry Up and Wait
Clicking ‘Publish’ on the dialog above begins the deployment process, which can easily take 15 minutes or more. During this time, some information is relayed through to Visual Studio about the actions being taken and their various statuses.
When the deployment is complete, click on the ‘Website URL’ link, or view the deployment in the Server Explorer and select ‘View in Browser’ from the right-click context menu.
The application finally appears. Note the URL is now that of an Azure cloud application.
In the Management Portal, expanding the Azure Subscription will show the Deployment node and all the compute instances fired up in the production environment. In our case, we have just one instance, but we could add more.
And there it is. A fully local web application that is now running in the cloud and using cloud-based blob and database storage.
Next we’ll talk about federating authentication to this application.