I was working on a Windows Azure application this weekend and I ran into a strange error. I was trying to access the metadata associated with blobs using (blob.FetchAttributes()) and received an error message. The problem was actually that the metadata wasn’t being associated properly with the blobs, so there was nothing to return. However, the error thrown was, “The specified blob does not exist.” Needless to say, I found this to be strange.
My solution was to check the metadata count before trying to fetch any metadata. This allowed my code to return blank results rather than throw a misleading error.
// Check for the case where attributes haven't been set
if (blob.Attributes.Metadata.Count > 0)
Update: Upon further investigation, I found that this didn’t work even when the BLOB metadata was properly set. If you run into this, check that you’re blob container reference isn’t null.