microsoft/aspire · error · NotSupportedException
Unsupported value type
Error message
Unsupported value type {value.GetType()} What it means
ProcessValue converts environment-variable/argument values for the website into Bicep parameters or secret references. It understands strings, primitives, IManifestExpressionProvider, and secret reference types; when it receives a value type outside its handled set it throws this NotSupportedException reporting the concrete CLR type via value.GetType().
Solutions
- Convert the value to a supported type before it reaches ProcessValue: use a string, a primitive, or an IManifestExpressionProvider (e.g. ReferenceExpression).
- If passing connection/endpoint objects, pass their .Value / expression form rather than the wrapper object.
- If you own a custom value provider, implement IManifestExpressionProvider so it resolves to a manifest expression.
- Inspect the reported type in the message to identify exactly which value failed and add a case for it if you're modifying the library.
Example fix
// before
api.WithEnvironment("MY_VALUE", new MyCustomValue());
// after
api.WithEnvironment("MY_VALUE", ReferenceExpression.Create($"{myCustomValue}")); // or .ToString()/string value Defensive patterns
Strategy: type-guard
Validate before calling
static bool IsSupportedProcessValueType(object v) =>
v is string or IManifestExpressionProvider or IAzureKeyVaultSecretReference || v is int or long or bool; Type guard
if (value is not (string or IManifestExpressionProvider))
throw new ArgumentException($"Convert {value.GetType().Name} to a string, ReferenceExpression, or secret reference before App Service processing."); Try / catch
try { var (param, _) = ctx.ProcessValue(value, secretType); }
catch (NotSupportedException ex) when (ex.Message.StartsWith("Unsupported value type"))
{
value = value.ToString(); // or wrap in ReferenceExpression
var (param, _) = ctx.ProcessValue(value, secretType);
} Prevention
- Pass strings, primitives, or IManifestExpressionProvider values to WithEnvironment/args on App Service projects.
- Unwrap connection/endpoint objects to their expression or string form first.
- Implement IManifestExpressionProvider on custom value providers.
When it happens
Trigger: Calling ProcessValue (directly or through environment/argument processing) with an unhandled object type — e.g. a custom IValueProvider that is not an IManifestExpressionProvider, a complex object, a BicepValue, or a raw Guid/DateTime not converted to string.
Common situations: Custom annotations supplying bespoke value types to WithEnvironment/args; passing connection-string or endpoint objects instead of their string/manifest forms; version changes where new value types (e.g. BicepValue inputs) were introduced but ProcessValue wasn't extended.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Unsupported value type
- Command line args must be strings
- Infra is not set
- The property ' ' is not supported for the endpoint ' '.
- Unsupported endpoint property
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/305a5f7cf06d4afd.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs:309
}
if (expr.StringFormats[index] is string format)
{
val = BicepFormattingHelpers.FormatBicepExpression(val, format);
}
args[index++] = val;
}
return (FormattableStringFactory.Create(expr.Format, args), finalSecretType);
}
if (value is IManifestExpressionProvider manifestExpressionProvider)
{
return (AllocateParameter(manifestExpressionProvider, secretType), secretType);
}
throw new NotSupportedException($"Unsupported value type {value.GetType()}");
}
private static BicepValue<string> ResolveValue(object val)
{
return val switch
{
BicepValue<string> s => s,
string s => s,
ProvisioningParameter p => p,
FormattableString fs => BicepFunction.Interpolate(fs),
_ => throw new NotSupportedException($"Unsupported value type {val.GetType()}")
};
}
public void BuildWebSite(AzureResourceInfrastructure infra)
{
_infrastructure = infra;
View on GitHub (pinned to 25830f84bd)