New Tutorial Series and Sample Application for ASP.NET MVC 4 with Windows Azure Tables, Blobs, and Queues

Tom Dykstra - MSFT

On December 19 we published a new tutorial series and accompanying sample application that shows how to work with Windows Azure Storage tables, queues, and blobs in a multi-tier application that uses ASP.NET MVC 4 and ASP.NET Web API.

The sample application is an email service that runs in a Windows Azure Cloud Service. The front-end is a web role that manages mailing lists, subscribers, and messages. The back-end is a pair of worker roles that handle scheduling and sending emails. 

There are five tutorials: one provides an overview of the application, one shows how to download and run the completed application, and three show how to build the application from scratch in Visual Studio.

Here are links to the tutorials, with a sampling of what you can find in them:

  • .NET Multi-Tier Application Using Storage Tables, Queues, and Blobs – 1 of 5
    • Front-end overview including screen shots of web pages.
    • Back-end overview including diagrams of application architecture.     
    • Schemas and sample contents for Windows Azure tables used by the application.
    • Explanations of how the application uses queues and blobs.
    • A data diagram for the tables and queues.
    • A discussion of relative merits of running the front-end as a web role in a Cloud Service vs. in a Windows Azure Web Site.
    • A discussion of operating costs and options for minimizing costs.
  • Configuring and Deploying the Windows Azure Email Service application – 2 of 5
    • How to download, configure, and run the application.
    • How to publish the application to the staging environment in your own Windows Azure account, and how to promote to production.
    • How to limit access to the application in Windows Azure by specifying IP restrictions.
    • How to use Azure Storage Explorer and Visual Studio to view data in Windows Azure development storage and Windows Azure Storage accounts.
    • How to use either the automated or manual method to add Windows Azure Storage account credentials to the Visual Studio project.
    • How to configure the application for tracing and how to view tracing data in Windows Azure Storage.
    • How to scale the application by adding web or worker role instances.
    • How to decrease project startup time by disabling development storage when you are using a Windows Azure Storage account.
  • Building the web role for the Windows Azure Email Service application – 3 of 5
    • How to create a solution that contains a Cloud Service project with a web role and a worker role.
    • How to work with Windows Azure tables, blobs, and queues in MVC 4 controllers and views.
      • How to handle basic CRUD operations.
      • How to upload files and store them in blobs.
      • How to handle changes to table data that involve changing the row key or the partition key of an entity.
      • How to handle concurrency conflicts.
      • How to set the retry policy to avoid subjecting the user to long wait times.
    • How to use the new Storage Client Library (SCL) 2.0 API (project templates still give you the 1.7 API by default).
    • How to reference an SCL 1.7 assembly in order to get diagnostic functionality that hasn’t been added to SCL 2.0 yet.
    • How to handle web role instance shutdown gracefully by overriding the OnStop method.
    • How to create tables, queues, and blobs in code so that you don’t have to create them manually.
    • How to limit Windows Azure Storage transaction costs, increase efficiency, and implement atomic transactions by performing table operations in batches of up to 100 operations.
    • How to run the web front-end in a Windows Azure Web Site instead of a Cloud Service
  • Building worker role A (email scheduler) for the Windows Azure Email Service application – 4 of 5
    • How to create, query, and update Windows Azure Storage tables in a worker role.
    • How to add work items to a queue for processing by another worker role.
    • How to set the appropriate connection limit and configure diagnostics in the OnStart method.
    • How to handle worker role instance shutdown gracefully by overriding the OnStop method.
    • How to make sure that no emails are missed and no duplicate emails are sent if the worker role instance shuts down unexpectedly.
    • How to test a worker role that uses Windows Azure Storage tables and queues.
  • Building worker role B (email sender) for the Windows Azure Email Service application – 5 of 5
    • How to add a worker role to a Cloud Service project.
    • How to poll a queue and process work items from the queue.
      • How to make sure that only one worker role instance gets any given queue work item for processing.
      • How increase efficiency and decrease transaction costs by getting up to 32 work items at a time.
      • How to handle “poison messages” that cause exceptions when the worker role tries to process them.
    • How to download text from blobs.
    • How to send emails by using SendGrid.
    • How to make sure that no emails are missed and no duplicate emails are sent if the worker role instance shuts down unexpectedly.

Feedback is welcome; you can post comments here or on the tutorials themselves.  One thing we know still needs work is the formatting of code blocks: the tutorials were written in Markdown, and we haven’t found a way to copy and paste code from Visual Studio into Markdown that preserves line spacing and indentation when the Markdown is rendered into HTML.  Suggestions for dealing with that issue are welcome also.

— Tom Dykstra


Comments are closed. Login to edit/delete your existing comments

Feedback usabilla icon