This error is very ambiguous and misleading, but there are times when "Azure Storage" can get confused. Considering the example of Sandrino and, in particular, this line,
[Microsoft.WindowsAzure.StorageClient.CloudBlob]$blob = $blobContainer.GetBlobReference($BlobName)
Not that Sandrino's answer is your problem, but the exception you encounter will happen when passing the URL or possibly other confusing key lines to Azure Storage Containers.
Unfortunately, I'm not a Powershell guy, but here is a playback example, and then fix it in C #.
public void Save(string objId, T obj) { CloudBlob blob = this.container.GetBlobReference(objId); // Problematic if a URL blob.Properties.ContentType = "application/json"; var serialized = string.Empty; serialized = serializer.Serialize(obj); if (this.jsonpSupport) { serialized = this.container.Name + "Callback(" + serialized + ")"; } blob.UploadText(serialized); }
Suppose this.container is a valid blob storage instance pointing to http://127.0.0.1:10000/devstoreaccount1/sggames or whatever you have for a valid container.
And objId is the key that contains the url, for example https://www.google.com/accounts/o8/id?id=AItOawk4Dw9sLxSc-zmdWQHdZNcyzkTcvKUkhiE ... and yes, this can happen, in my case this is the actual claim from Google using Azure ACS.
After calling GetBlobReference, the blob instance became corrupt, which now looks confused Uri → https://www.google.com/accounts/o8/id?id=AItOawk4Dw9sLxSc-zmdWQHdZNcyzkTcvKUkhiE
Unfortunately, the solution to just calling $ blobContainer.CreateIfNotExist () is not a solution and will not work. The key containing the Uri structure will simply be used to re-interpret the blob storage location.
The work around (except the daredev update) will be something like this:
if (Uri.IsWellFormedUriString(claim, UriKind.Absolute) && HttpUtility.ParseQueryString(claim).Count > 0) { claim = HttpUtility.ParseQueryString(claim)[0]; }
Add this code to my method above to clear all Uri, but you can use any suitable method, such as Base64 encoding URLs, if you need to save the full key.
Here are the before and after images showing the results as I described.
Bad:
note the bad URI
this bad URI mixed up the actual location of the memory location
here is the same exception daredev had
Good:
new cleared key, pay attention only to the value in the query string URL
Laser storage URI now looks good
Eureka!
Hope this helps.