다음을 통해 공유


Azure Storage Naming Rules

I constantly get burned by naming rules for azure storage. Here’s a collection of the naming rules from MSDN. The Storage client libraries don’t help you with these rules and just give you a 400 if you get them wrong. Fortunately, WebJobs SDK will provide client-side validation and give you more friendly messages.

Here’s a summary of rules in table form:

You’ll notice blobs, tables, and queues all have different naming rules.

Here are the relevant excerpts from MSDN with more details.

Storage account names

Storage account names are scoped globally (across subscriptions).

Between 3 and 24 characters.  Lowercase letters and numbers . 

Blobs

From MSDN here.

Blob Names

A blob name can contain any combination of characters, but reserved URL characters must be properly escaped. A blob name must be at least one character long and cannot be more than 1,024 characters long. Blob names are case-sensitive.

Avoid blob names that end with a dot (.), a forward slash (/), or a sequence or combination of the two.

By convention / is the virtual directory separator. Don’t use \ in a blob name. The client APIs may allow it, but then fail to hash properly and the signatures mismatch

Blob Metadata Names

Metadata for a container or blob resource is stored as name-value pairs associated with the resource. Metadata names must adhere to the naming rules for C# identifiers.

Note that metadata names preserve the case with which they were created, but are case-insensitive when set or read. If two or more metadata headers with the same name are submitted for a resource, the Blob service returns status code 400 (Bad Request).

Container Names

A container name must be a valid DNS name, conforming to the following naming rules:

  1. Container names must start with a letter or number, and can contain only letters, numbers, and the dash (-) character.
  2. Every dash (-) character must be immediately preceded and followed by a letter or number; consecutive dashes are not permitted in container names.
  3. All letters in a container name must be lowercase.
  4. Container names must be from 3 through 63 characters long.

Queues

From MSDN:

Every queue within an account must have a unique name. The queue name must be a valid DNS name.

Queue names must confirm to the following rules:

  1. A queue name must start with a letter or number, and can only contain letters, numbers, and the dash (-) character.
  2. The first and last letters in the queue name must be alphanumeric. The dash (-) character cannot be the first or last character. Consecutive dash characters are not permitted in the queue name.
  3. All letters in a queue name must be lowercase.
  4. A queue name must be from 3 through 63 characters long.

Tables

Name of the table

Table names must conform to these rules:

  • Table names must be unique within an account.
  • Table names may contain only alphanumeric characters.
  • Table names cannot begin with a numeric character.
  • Table names are case-insensitive.
  • Table names must be from 3 to 63 characters long.
  • Some table names are reserved, including "tables". Attempting to create a table with a reserved table name returns error code 404 (Bad Request).

These rules are also described by the regular expression "^[A-Za-z][A-Za-z0-9]{2,62}$".

Table names preserve the case with which they were created, but are case-insensitive when used.

Valid property names

Property names are case-sensitive strings up to 255 characters in size. Property names should follow naming rules for C# identifiers. (The dash is no longer allowed)

Valid values for PartitionKey and RowKey

The following characters are not allowed in values for the PartitionKey and RowKey properties:

  • The forward slash (/) character
  • The backslash (\) character
  • The number sign (#) character
  • The question mark (?) character
  • Control characters from U+0000 to U+001F, including:
    • The horizontal tab (\t) character
    • The linefeed (\n) character
    • The carriage return (\r) character
  • Control characters from U+007F to U+009F

Comments

  • Anonymous
    June 19, 2014
    The annoyance here is that the relevant parts of Azure Storage will not always throw and error if you use the wrong naming conventions, rather they can just fail silently. This causes hours of debugging before you realise that you've used an uppercase character in your storage-queue name.

  • Anonymous
    June 20, 2014
    @njpatel - absolutely agreed. That's one big benefit to using the WebJobs SDK (azure.microsoft.com/.../announcing-the-0-3-0-beta-preview-of-microsoft-azure-webjobs-sdk ) - it's a wrapper over storage that will do things like enforce these naming rules and give you nice errors.

  • Anonymous
    July 10, 2018
    After chasing down naming issues all day. It is important to note that these rules do not apply to Queues in Service Bus... It might not be a bad idea to specifically call that out in the article.