dotnet/orleans · error · ArgumentException
Invalid container name
Error message
Invalid container name
What it means
Thrown by AzureBlobUtils.ValidateContainerName when the container name is blank, shorter than 3, longer than 63 characters, or does not match the pattern ^[a-z0-9]+(-[a-z0-9]+)*$ (lowercase alphanumeric with single dashes between groups). These are Azure Blob storage naming rules enforced client-side.
Source
Thrown at src/Azure/Shared/Storage/AzureBlobUtils.cs:25
#elif ORLEANS_STREAMING
namespace Orleans.Streaming.AzureStorage
#else
// No default namespace intentionally to cause compile errors if something is not defined
#endif
{
/// <summary>
/// General utility functions related to Azure Blob storage.
/// </summary>
internal static partial class AzureBlobUtils
{
[GeneratedRegex("^[a-z0-9]+(-[a-z0-9]+)*$", RegexOptions.ExplicitCapture | RegexOptions.Singleline | RegexOptions.CultureInvariant)]
private static partial Regex ContainerNameRegex();
internal static void ValidateContainerName(string containerName)
{
if (string.IsNullOrWhiteSpace(containerName) || containerName.Length < 3 || containerName.Length > 63 || !ContainerNameRegex().IsMatch(containerName))
{
throw new ArgumentException("Invalid container name", nameof(containerName));
}
}
internal static void ValidateBlobName(string blobName)
{
if (string.IsNullOrWhiteSpace(blobName) || blobName.Length > 1024 || blobName.Count(c => c == '/') >= 254)
{
throw new ArgumentException("Invalid blob name", nameof(blobName));
}
}
}
}
View on GitHub (pinned to fca799fa70)
Solutions
- Normalize the name to lowercase alphanumeric with single internal dashes (e.g. "orleans-grain-state").
- Ensure length is between 3 and 63 characters.
- Replace invalid characters (underscores -> dashes) and collapse consecutive/trailing dashes.
- Validate the name against the regex before passing it in.
Example fix
// before var container = "Orleans_GrainState"; // uppercase + underscore -> invalid // after var container = "orleans-grain-state";
Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(containerName) || containerName.Length < 3 || containerName.Length > 63
|| !Regex.IsMatch(containerName, @"^[a-z0-9]+(-[a-z0-9]+)*$"))
throw new ArgumentException("Invalid container name"); Type guard
static bool IsValidContainerName(string? n) =>
!string.IsNullOrWhiteSpace(n) && n.Length is >= 3 and <= 63
&& Regex.IsMatch(n, @"^[a-z0-9]+(-[a-z0-9]+)*$"); Prevention
- Normalize container names to lowercase alphanumeric with single internal dashes.
- Generate container names from a known-safe alphabet only.
When it happens
Trigger: Supplying a container name that violates Azure naming rules: uppercase letters, underscores, leading/trailing/consecutive dashes, wrong length, or whitespace.
Common situations: Using an environment/project name with uppercase or underscores as the container; a computed name that is too short or empty; trailing dash from string trimming.
Related errors
- Named option AzureBlobLeaseProviderOptions of name {name} is
- Azure Table names must contain 3 to 63 alphanumeric characte
- No credentials specified. Use the AzureBlobStorageOptions.Co
- Configuration for AzureBlobStorageOptions {name} is invalid.
- Configuration for AzureBlobLeaseProviderOptions {name} is in
AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13).
Data as JSON: /api/errors/41fb409bb49b13f2.
Report an issue: GitHub.