I’ve been travelling around giving a two-part talk called “Azure for Developers”, in which I show how and why to use each of the features of Windows Azure. I do this by building a WCF service that performs CRUD operations against a SQL Azure database or Windows Azure Table Storage, and setting up a client application to call the service. The point is to show the features of Windows Azure and talk about how I’ve used them in production, and focus on the programming.
I’m turning the talk into a series of seven blog posts in case other people find it helpful, especially if you’re just starting out with Windows Azure development. This series will give you all of the code to create a working service that you can run in the cloud or in the compute emulator, and a client that you can run to test the service. I will also provide the database structure and stored procedures. So if you follow all of the instructions, then by the end of step 7, you should have your own version of the working service, and you will know how to create a web role and a worker role, and how to programmatically talk to SQL Azure, Windows Azure queues, Windows Azure table storage, and Windows Azure blob storage.
Let’s start with the objective of the service – what is it going to do? Here is what the client application looks like. We’re basically going to write the backend for this application and then hook up the application to call the backend.
We will have four fields that the user can add, update, and retrieve. They can also add a message to a queue, and we will retrieve the message from the queue and write their information out to blob storage.
Let’s talk about the architecture of the whole application. Here’s what we will be creating:
- A database with a table and the stored procedures to retrieve the data (provided)
- A web role hosting a WCF service that exposes methods that correspond to the features of the client application, and reads/writes to the SQL Azure database and to put messages on a Windows Azure queue.
- A worker role that will check the queue for messages and retrieve them, then write them to blob storage.
- A client application to call the WCF service and show the results. (provided)
To follow along and create your own working version of the client and the service, you need the following:
- SQLServer Express or SQLServer installed on your local machine (SQLCE won’t work)
- If you want to run the service in the cloud, you need a Windows Azure subscription with at least one service, one storage account, and one SQL Azure server. You can do this entire series in the compute emulator without publishing to the cloud.
- Visual Studio 2010 or 2012 with the Tools/SDK 1.6 or 1.7 installed. The finished projects I post at the end will use VS2010 and target 1.6 for the widest audience.
- An application you can use to view Blob Storage, Table Storage, Queues, and Diagnostics. I use (and will show) the Cerebrata tools, or you can use the (free) Windows Azure Platform Management Tool (MMC) on Codeplex, or any other tool you may prefer.
You need the starting version of the desktop application (without the service code). You can download that here.
You need the CodeCamp database, which you can download here.
Here is the list of steps in the tutorial, in case you want to look ahead.
- Step 1: Migrating the database to Windows Azure
- Step 2: Creating the WCF service, part 1
- Step 3: Creating the WCF service, part 2
- Step 4: Calling the WCF service from the client
- Step 5: Adding messages to a queue
- Step 6: Processing the queue
- Step 7: Use Table Storage instead of a SQL Database
Tags: Windows Azure