microsoft/aspire · error · NotSupportedException
The scope value type
Error message
The scope value type {scopeValue.GetType()} is not supported. What it means
ResolveScopeValueAsync supports only string and IValueProvider scope values; any other object type hits the NotSupportedException fallback arm. The message includes the concrete runtime type so developers know what leaked into the scope property.
Solutions
- Convert the value to a string before assigning it as the scope (e.g. .ToString() or reference type/value provider helpers).
- Use builder.CreateResourceBuilder/parameter references so the scope is an IValueProvider instead of a raw object.
- If using a custom value type, implement IValueProvider (or wrap it in one) so it resolves via GetValueAsync.
- Check the reported type name in the message and map it to the supported string/IValueProvider forms.
Example fix
// before
resource.Scope = new ResourceId("/subscriptions/..."); // unsupported type
// after
resource.Scope = "/subscriptions/.../resourceGroups/rg"; // or an IValueProvider Defensive patterns
Strategy: type-guard
Validate before calling
static bool IsSupportedScopeValue(object? value) => value is string or IValueProvider;
Type guard
static string? ResolveScopeSync(object scopeValue) => scopeValue switch
{
string s => s,
IValueProvider vp => vp.GetValueAsync(default).GetAwaiter().GetResult() as string,
_ => null
}; Try / catch
try
{
await provisioner.GetOrCreateResourceAsync(resource, ct);
}
catch (NotSupportedException ex) when (ex.Message.Contains("scope value type"))
{
logger.LogError(ex, "Unsupported scope type assigned; use a string or IValueProvider.");
} Prevention
- Only assign strings or IValueProvider instances to scope settings.
- Convert typed identifiers (ResourceIds, URIs) to strings before assignment.
- For dynamic values, wrap them in an IValueProvider implementation.
When it happens
Trigger: Assigning an unsupported object (e.g. an endpoint reference, custom wrapper type, or IResource instead of an IValueProvider/string) to a resource's scope setting consumed by ResolveScopeValueAsync.
Common situations: Passing a strongly-typed value (ResourceId, URI object, builder expression) where a string or IValueProvider is expected; upgrading Aspire where scope APIs tightened; hand-written custom scope types.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- A of type cannot be assigned to a BicepValue< >.
- Expected a string, integer, or
- Expected a literal or .
- The Azure resource scope value cannot be null.
- The Azure scope value type
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/a11cd8bf7d9e9178.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure/Provisioning/Provisioners/BicepProvisioner.cs:1289
return details.Count == 0 ? string.Empty : $" ({string.Join("; ", details)})";
void AddDetail(string name, string? value)
{
if (!string.IsNullOrEmpty(value))
{
details.Add($"{name}: {value}");
}
}
}
private static async Task<string> ResolveScopeValueAsync(object scopeValue, CancellationToken cancellationToken)
{
return scopeValue switch
{
string value => value,
IValueProvider valueProvider => await valueProvider.GetValueAsync(cancellationToken).ConfigureAwait(false) ?? throw new InvalidOperationException("The Azure resource scope value cannot be null."),
_ => throw new NotSupportedException($"The scope value type {scopeValue.GetType()} is not supported.")
};
}
private async Task<bool> TryCancelDeploymentAsync(IArmDeploymentCollection deployments, string deploymentName, ILogger resourceLogger, bool treatMissingOrInactiveAsCanceled)
{
try
{
await deployments.CancelAsync(deploymentName, CancellationToken.None).ConfigureAwait(false);
resourceLogger.LogInformation("Cancellation requested for Azure deployment {DeploymentName}.", deploymentName);
return true;
}
catch (RequestFailedException ex) when (treatMissingOrInactiveAsCanceled && (ex.Status == 404 || ex.Status == 409))
{
logger.LogInformation(ex, "Azure deployment {DeploymentName} was already absent or no longer active during cancellation.", deploymentName);
resourceLogger.LogInformation("Azure deployment {DeploymentName} was already absent or no longer active during cancellation.", deploymentName);
return true;
}
catch (RequestFailedException ex)View on GitHub (pinned to 25830f84bd)