Monthly Archives: October 2010

An HTTP header that’s mandatory for this request is not specified: One Cause for Azure Error Message

I recently posted sample code that shows copying a file up to Azure Blob Storage in One Page Of Code. In repurposing the code that deals with Azure Queues, I encountered a perplexing error message in using the Azure CloudQueue class from the SDK. I was able to figure it out, and the actual solution may actually be less interesting than how the solution was discovered, so here it is…

The story of “an HTTP header that’s mandatory for this request is not specified”

First of all, my call to get a queue reference had completed without incident:

queue = queueStorage.GetQueueReference(“myqueue”);

Next I executed this line of seemingly innocuous code:

queue.CreateIfNotExist();

An Exception was raised – a “Microsoft.WindowsAzure.StorageClient.StorageClientException” to be exact – with the following message:

Exception Message: “An HTTP header that’s mandatory for this request is not specified” 

“An HTTP header that’s mandatory for this request is not specified.”

"An HTTP header that's mandatory for this request is not specified."

That didn’t help, so I then checked the Inner Exception:

Inner Exception Message: “The remote server returned an error: (400) Bad Request.”

"The remote server returned an error: (400) Bad Request."

That didn’t help either. So I fired up Fiddler and looked at the http Request and Response (Raw views shown here):

Screen shot mentioning “Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0” and “<HeaderName>x-ms-blob-type</HeaderName>”

If you look carefully in the Response, you will see there are two references to Blobs:

Circled “Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0” and “<HeaderName>x-ms-blob-type</HeaderName>”

Blobs? Yes, blobs.

Blobs… That was my problem. This was supposed to be code to create a queue. A quick check back to my code immediately revealed a cut and paste error on my part. Two actually, as I tried this both against Development Storage and against live Cloud Storage with the same error.

This was the problem – the culpret – the issue – the bug:

    var clientStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
    CloudQueueClient queueStorage = new CloudQueueClient(clientStorageAccount.BlobEndpoint.AbsoluteUri,clientStorageAccount.Credentials);

As was this:

    CloudQueueClient queueStorage = new CloudQueueClient(String.Format(“http://{0}.blob.core.windows.net”, accountName), creds);

Replacing “Blob” with “Queue” did the trick for both snippets.

Pay the Fiddler

The error message was tricky, requiring that I fire up Fiddler to see the error of my ways. So..  Be careful out there when you Cut & Paste. Or don’t hack at 9:30 in the night. Or check out a Fiddler http trace, which may have additional information. Or all three..

Checking the Fiddler trace is really the interesting lesson from this post. If you are perplexed over some error condition, look at the raw http traffic for additional details – there may be a new clue in there.

Did This Post Help You?

Please leave me a comment if this blog post helped you or if you encountered the same exact error.

Advertisements

Why Don’t Windows Azure Libraries Show Up In Add Reference Dialog when Using .NET Framework Client Profile?

You are writing an application for Windows – perhaps a Console App or a WPF Application – or maybe an old-school Windows Forms app.  Every is humming along. Then you want to interact with Windows Azure storage. Easy, right? So you Right-Click on the References list in Visual Studio, pop up the trusty old Add Reference dialog box, and search for Microsoft.WindowsAzure.StorageClient in the list of assemblies.

But it isn’t there!

You already know you can’t use the .NET Managed Libraries for Windows Azure in a Silverlight app, but you just know it is okay in a desktop application.

You double-check that you have installed Windows Azure Tools for Microsoft Visual Studio 1.2 (June 2010) (or at least Windows Azure SDK 1.2 (last refreshed from June in Sept 2010 with a couple of bug-fixes)).

You sort the list by Component Name, then leveraging your absolute mastery of the alphabet, you find the spot in the list where the assemblies ought to be, but they are not there. You see the one before in the alphabet, the one after it in the alphabet, but no Microsoft.WindowsAzure.StorageClient assembly in sight. What gives?

Look familiar? Where is the Microsoft.WindowsAzure.StorageClient assembly?

Confirmation Dialog after changing from Client Profile to full .NET

Azure Managed Libraries Not Included in .NET Framework 4 Client Profile

If your eyes move a little higher in the Add Reference dialog box, you will see the problem. You are using the .NET Framework 4 Client Profile. Nothing wrong with the Client Profile – it can be a friend if you want a lighter-weight version of the .NET framework for deployment to desktops where you can’t be sure your .NET platform bits are already there – but Windows Azure Managed Libraries are not included with the Client Profile.

image

Bottom line: Windows Azure Managed Libraries are simply not support in the .NET Framework 4 Client Profile

How Did This Happen?

It turns out that in Visual Studio 2010, the default behavior for many common project types is to use the .NET Framework 4 Client Profile. There are some good reasons behind this, but it is something you need to know about. It is very easy to create a project that uses the Client Profile because it is neither visible – and with not apparent option for adjustment – on the Add Project dialog box – all you see is .NET Framework 4.0:

The “Work-around” is Simple: Do Not Use .NET Framework 4 Client Profile

While you are not completely out of luck, you just can’t use the Client Profile in this case. And, as the .NET Framework 4 Client Profile documentation states:

If you are targeting the .NET Framework 4 Client Profile, you cannot reference an assembly that is not in the .NET Framework 4 Client Profile. Instead you must target the .NET Framework 4.

So let’s use the (full) .NET Framework 4.

Changing from .NET Client Profile to Full .NET Framework

To move your project from Client Profile to Full Framework, right-click on your project in Solution Explorer (my project here is called “SnippetUploader”):

image

From the bottom of the pop-up list, choose Properties.

image

This will bring up the Properties window for your application. It will look something like this:

image

Of course, by now you probably see the culprit in the screen shot: change the “Target framework:” from “.NET Framework 4 Client Profile” to “.NET Framework 4” (or an earlier version) and you have one final step:

image

Now you should be good to go, provided you have Windows Azure Tools for Microsoft Visual Studio 1.2 (June 2010) installed. Note, incidentally, that the Windows Azure tools for VS mention support for

…targeting either the .NET 3.5 or .NET 4 framework.

with no mention of support the .NET Client Profile. So stop expecting it to be there!



You can’t add a reference to Microsoft.WindowsAzure.StorageClient.dll as it was not build against the Silverlight runtime

Are you developing Silverlight apps that would like to talk directly to Windows Azure APIs? That is perfectly legal, using the REST API. But if you want to use the handy-dandy Windows Azure Managed Libraries – such as Microsoft.WindowsAzure.StorageClient.dll to talk to Windows Azure Storage – then that’s not available in Silverlight.

As you may know, Silverlight assembly format is a bit different than straight-up .NET, and attempting to use Add Reference from a Silverlight project to a plain-old-.NET assembly just won’t work. Instead, you’ll see something like this:

Visual Studio error message from use of Add Reference in a Silverlight project: "You can’t add a reference to Microsoft.WindowsAzure.StorageClient.dll as it was not build against the Silverlight runtime. Silverlight projects will only work with Silverlight assemblies."

If you pick a class from the StorageClient assembly – let’s say, CloudBlobClient – and check the documentation, it will tell you where this class is supported:

Screen clipping from the StorageClient documentation with empty list of Target Platforms

Okay – so maybe it doesn’t exactly – the Target Platforms list is empty – presumably an error of omission. But going by the Development Platforms list, you wouldn’t expect it to work in Silverlight.

There’s Always REST

As mentioned, you are always free to directly do battle with the Azure REST APIs for Storage or Management. This is a workable approach. Or, even better, expose the operations of interest as Azure services – abstracting them as higher level activities. You have heard of SOA, haven’t you? 🙂

“Cloud Computing 101, Azure Style!” and “Building Cloud-Native Applications on Azure” – Two Talks I Presented at New England Code Camp 14

Yesterday I attended New England Code Camp 14 (check out the #necc14 twitter stream while it lasts). I enjoyed many talks:

  1. Maura Wilder on JavaScript Debugging (@squdgy)
  2. Jason Haley on Comparing the Azure and Amazon Cloud Platforms (@haleyjason)
  3. Jim O’Neil on Dissecting the Azure @Home Application (@jimoneil)
  4. Abby Fichtner on Lean Startups (@hackerchick)
  5. MC’d by Abby, various folks talking about their experiences at startups — 4 talks jam-packed into a fast-paced one-hour session:
    1. Vishal Kumar of savinz.com (“mint.com for shopping”)
    2. Allison Friedman (@rateitgreen) of Rate It Green (“yelp for the green building industry”)
    3. Sean Creely (@screeley) of Embedly (“make friendly embedded links”) – a Y Combinator company providing a service for turning tweets containing media links into something more user friendly (e.g., embed inline YouTube video rather than a link taking you to YouTube)
    4. Marc Held (@getzazu) of getzazu.com (“alarm clock 2.0”)

At Uno’s afterwards, I enjoyed chatting with many folks, including Veronica and Shawn Robichaud (all the way from Maine!), John from BUGC and Blue Fin, Slava Kokaev, entrepreneurs Marc, Billy, Brian, Vishal, and Dan Colon, dev evangelists Jim O’Neil and Chris Bowen, Yilmaz Rona from Trilogy, and of course Maura.

At the Code Camp, I presented twice on Azure-focused topics:

  1. Cloud Computing 101: Azure Style! – an introduction to cloud computing, and an overview of the services that Microsoft’s cloud stack offers
  2. Building Cloud-Native Applications with Azure – a mind-blowing tour of some of the changes that await the technology community as we move our world into the cloud

The Boston Azure User Group is one year old! You can follow the group on twitter @bostonazure. You can also follow me on twitter @codingoutloud. And I hope to see you at the next Boston Azure meeting on Thurs October 21 from 6:00-8:30 PM at NERD (registration and more info).