microsoft/aspire · error · ArgumentException
Connector Namespace resource names can contain only ASCII…
Error message
Connector Namespace resource names can contain only ASCII letters, numbers, hyphens, and underscores.
What it means
Connector Namespace resource names must use only ASCII letters, digits, hyphens, and underscores; Azure rejects any other character. ValidateConnectorResourceName throws ArgumentException naming the offending parameter when any character falls outside this set.
Solutions
- Remove or replace disallowed characters (e.g. '.' -> '-')
- Use a sanitizer that maps the name to [A-Za-z0-9_-] only
- Avoid deriving names directly from paths, URLs, or user input
Example fix
// before
.AddConnection("my app.conn", ...)
// after
.AddConnection("my-app-conn", ...) Defensive patterns
Strategy: validation
Validate before calling
if (name.Any(c => !char.IsAsciiLetterOrDigit(c) && c is not '-' and not '_'))
throw new ArgumentException("Name must contain only ASCII letters, digits, '-', '_'.", nameof(name)); Try / catch
try { builder.AddConnection(name, ...); }
catch (ArgumentException ex) { log.LogError(ex, "Name contains invalid characters"); } Prevention
- Sanitize names derived from paths/URLs/user input
- Use a canonical slug function for all resource names
- Avoid non-ASCII identifiers in infrastructure code
When it happens
Trigger: Passing a name containing spaces, dots, slashes, or non-ASCII/Unicode characters to AddConnection, WithAccessPolicy, WithIdentityAccessPolicy, or AddMcpServerConfig.
Common situations: Deriving names from project paths or URLs (dots/slashes), using localized or emoji characters, copying names with trailing spaces or casing artifacts.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- Connector Namespace resource names must contain between 2…
- Secret name cannot be longer than 127 characters.
- A purge task with the name
- App Service configuration validation failed. See errors…
- ASPIRERADIUS049
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/c8544d42081cc166.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure.ConnectorNamespace/AzureConnectorNamespaceExtensions.cs:765
}
}
private static void ValidateConnectorResourceName(string name, string paramName)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name, paramName);
if (name.Length is < 2 or > 64)
{
throw new ArgumentOutOfRangeException(
paramName,
name,
"Connector Namespace resource names must contain between 2 and 64 characters.");
}
if (name.Any(static character =>
!char.IsAsciiLetterOrDigit(character) &&
character is not '-' and not '_'))
{
throw new ArgumentException(
"Connector Namespace resource names can contain only ASCII letters, numbers, hyphens, and underscores.",
paramName);
}
}
}
View on GitHub (pinned to 25830f84bd)