VS2010: Cloud Development
By Tim Anderson
Targeting Windows Azure with Visual Studio 2010.
HardCopy Issue: 52 | Found In: Visual Studio 2010 | Published: 19/05/2011 | Last Revision: 19/05/2011
Creating a new hosted service in the Azure developer portal.
Windows Azure is Microsoft’s cloud platform for hosting applications. Instead of deploying applications to your own servers, you install them externally on Microsoft’s Azure infrastructure, so removing the burden of maintenance and capital expenditure, and making it easier to scale to demand.
Azure has a pay-as-go model so you pay an hourly fee for compute ‘instances’, ranging from ‘Extra Small’ to ‘Extra Large’, where each instance is a virtual machine dedicated to running your application. You can use Remote Desktop to access Azure instances, which means you can check the event log or perform other troubleshooting steps. However Azure instances are inherently stateless, and the system can revert them back to their state when last deployed, so conceptually they should be seen as a platform for running applications rather than a Windows server in the cloud.
The cost of an Azure instance cannot be directly compared to purchasing a single virtual machine from an ISP. Azure is a fully serviced platform, with Microsoft responsible for maintenance and resilience. Microsoft says, for example, that all Azure content is replicated three times over.
Azure is supported by several additional services. SQL Azure is hosted SQL Server, priced per database and tiered according to size. Another feature is synchronization between SQL Azure instances, or between SQL Azure and on-premise SQL Servers. SQL Reporting is a feature in preview.
Getting started with Azure
An Azure Web application can be built and deployed in just a few steps. Here is how you can create a simple ASP.NET application using Visual Studio 2010 with the Azure Tools 1.4. These tools are easily installed using Microsoft’s Web Platform Installer.
Before you begin, there are a couple of prerequisites. First, you have to set up an Azure account. MSDN subscribers get a certain amount free, depending on subscription level. This gives you access to the Azure developer portal, where you can add and manage services. You will need to log in and create a new hosted service for your application.
Next, run Visual Studio 2010 as administrator with the Azure Tools installed. Start a new project and select a Cloud project for your preferred language. The wizard will ask you to select one or more roles for the project. Here we would use an ASP.NET Web Role.
The solution opens and you can create an ASP.NET application in the usual way. Debugging is a little different since it runs on the Azure Development Fabric, a local emulation of the Azure platform, and if needed on the Development Storage as well.
When the application is ready to be deployed, right-click the WebRole in the solution explorer and check its properties. Here you can set the VM size, instance count and other Azure-specific settings. The Extra Small instance is ideal for test and development.
Next, right-click the project and choose Publish. Here you can enter your Azure account credentials, choose a hosted service, and optionally configure IntelliTrace debugging and remote desktop connection. You will have to generate certificates for some operations, but the wizards guide this.
Finally, click OK to deploy the project to Azure. This takes a little while as Azure needs to configure and spin up your virtual machine instance, but once deployed you should find that performance is good.
Azure Binary Large Object storage is for storing arbitrary files such as documents or images. The Table service is for structured non-relational data. The Queue service handles reliable messaging between instances.
Then there is Windows Server AppFabric, a cloud middleware platform. Access Control provides federated authorisation, including the ability to link with your local active directory for single sign-on between the internal network and the cloud. The AppFabric Service Bus is a secure messaging service that integrates with Windows Communication Foundation. AppFabric caching is a cache service that can greatly improve performance. AppFabric integration, currently under development, brings BizTalk Server features to Azure.
Windows Azure classifies applications into ‘roles’ which can be combined in a solution. A Web role installs into IIS7 and ASP.NET, while a worker role is for background processing. You can also have a Silverlight Business role, which is for Web services to support Silverlight clients, and a CGI role for FastCGI applications (often built with PHP).
Visual Studio 2010 also comes with a local Azure Development Fabric and Storage which means you can test your Azure applications using the same simple click-and-run that developers are familiar with.
Azure is in line with Microsoft’s strategy of providing both cloud and on-premise platforms with excellent integration. Active Directory Federation Services is key, since it brings together existing Active Directory infrastructure with the new world of Azure deployment. Interoperability is another theme, based on the use of standard HTTP, SOAP and REST protocols plus support for PHP.