microsoft/aspire · error · ArgumentException

Connector operation ' ' is configured more than once.

Error message

Connector operation '{operation.Name}' is configured more than once.

What it means

Each connector operation must have a unique name (compared case-insensitively via a HashSet). WithConnector throws this ArgumentException when two operations in options.Operations share the same name, since duplicate names would produce conflicting MCP operation definitions.

Solutions

  1. Rename one of the duplicate operations so every Name is unique (case-insensitively).
  2. Deduplicate the list before calling WithConnector, e.g. GroupBy(op => op.Name, StringComparer.OrdinalIgnoreCase).First().
  3. Centralize operation definitions so the same operation is not added twice.

Example fix

// before
Operations = new[]
{
    new AzureConnectorNamespaceConnectorOperation { Name = "GetItem" },
    new AzureConnectorNamespaceConnectorOperation { Name = "getitem" }
}
// after
Operations = new[]
{
    new AzureConnectorNamespaceConnectorOperation { Name = "GetItem" },
    new AzureConnectorNamespaceConnectorOperation { Name = "GetItemDetails" }
}
Defensive patterns

Strategy: validation

Validate before calling

var dupes = options.Operations
    .GroupBy(op => op.Name, StringComparer.OrdinalIgnoreCase)
    .Where(g => g.Count() > 1)
    .Select(g => g.Key).ToList();
if (dupes.Count > 0) throw new InvalidOperationException($"Duplicate operation names: {string.Join(", ", dupes)}");

Try / catch

try { builder.WithConnector(options); }
catch (ArgumentException ex) when (ex.Message.Contains("more than once"))
{
    // deduplicate operations and retry
}

Prevention

When it happens

Trigger: Calling WithConnector with two operations whose Name values match ignoring case, e.g. "GetItem" and "getitem" in the same Operations array.

Common situations: Merging operation lists from multiple sources without deduplicating; copy-pasting an operation entry and changing only its parameters; case differences hiding duplicates during review.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/aa333c782ca2af69. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.Azure.ConnectorNamespace/AzureConnectorNamespaceExtensions.cs:630

        }

        var operationNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
        var connectorDefinition = new AzureConnectorNamespaceMcpConnectorDefinition(
            connectorName,
            options.DisplayName,
            options.Description,
            connection.Resource);
        foreach (var operation in options.Operations)
        {
            if (operation is null)
            {
                throw new ArgumentException("Connector operations cannot contain null values.", nameof(options));
            }

            ArgumentException.ThrowIfNullOrWhiteSpace(operation.Name);
            if (!operationNames.Add(operation.Name))
            {
                throw new ArgumentException(
                    $"Connector operation '{operation.Name}' is configured more than once.",
                    nameof(options));
            }

            connectorDefinition.Operations.Add(new AzureConnectorNamespaceMcpOperationDefinition(
                operation.Name,
                operation.DisplayName,
                operation.Description));
        }

        builder.Resource.Connectors.Add(connectorDefinition);
        return builder;
    }

    private static BicepValue<string> GetOptionalIdentityProperty(ConnectorGateway gateway, string propertyName)
    {
        // Existing namespaces can have no identity or a user-assigned-only identity. Safe member access
        // preserves available system-assigned values without making output evaluation fail when absent.

View on GitHub (pinned to 25830f84bd)