Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identify Invalid Azure Container Names [closed]

How can one programmatically determine if a container name is invalid per the rules?


Valid naming for a Container in Azure Blob Storage.

  1. 3 to 63 Characters
  2. Starts With Letter or Number
  3. Letters, Numbers, and Dash (-)
  4. Every Dash (-) Must Be Immediately Preceded and Followed by a Letter or Number
  5. All letters in a container name must be lowercase.
like image 509
Poul K. Sørensen Avatar asked May 08 '13 17:05

Poul K. Sørensen


1 Answers

Valid naming for a Container in Azure Blob Storage.

  1. 3 to 63 Characters
  2. Starts With Letter or Number
  3. Letters, Numbers, and Dash (-)
  4. Every Dash (-) Must Be Immediately Preceded and Followed by a Letter or Number
  5. All letters in a container name must be lowercase.

In my WebAPI i used the following:

        if (container.Length < 3 ||
            container.Length > 63 ||
            !Regex.IsMatch(container, @"^[a-z0-9]+(-[a-z0-9]+)*$"))
            throw new HttpResponseException(Request.CreateResponse(
                HttpStatusCode.BadRequest, "Invalid Request!"));
like image 52
Poul K. Sørensen Avatar answered Sep 25 '22 00:09

Poul K. Sørensen