Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

A Vague Error While Creating Azure Blob Storage Container

DZone's Guide to

A Vague Error While Creating Azure Blob Storage Container

· Cloud Zone
Free Resource

Linkerd, the open source service mesh for cloud native applications. Get the complete guide to using Linkerd and Kubernetes to build scalable, resilient applications.

I received a rather...vague...error when trying out a bit of .NET code to connect to a Windows Azure Blob Storage account, and create a new container in which to store some blobs.

The code

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
    "DefaultEndpointsProtocol=https;AccountName=REMOVED;AccountKey=REMOVED");

CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
            
CloudBlobContainer container = 
    blobClient.GetContainerReference("TestContainer1");

container.CreateIfNotExist(); // This error'd

The error

A StorageClientException was thrown saying "One of the request inputs is out of range.". An inner WebException showed that "The remote server returned an error: (400) Bad Request."

The cause

I'd assumed (incorrectly) that a container name could be pretty much any string. But that's not the case. As per this MSDN reference, a container name must:
  • be in lowercase (this was the cause in my case)
  • start with a letter or a number and only contain letters, numbers and hyphens (multiple consecutive hyphens are not allowed)
  • be between 3 and 63 characters long
The " Naming and Referencing Containers, Blobs and Metadata" reference is worth a bookmark.

Linkerd, the open source service mesh for cloud native applications. Get the complete guide to using Linkerd and Kubernetes to build scalable, resilient applications.

Topics:

Published at DZone with permission of Adrian Hills, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}