Skip to content

Unhandled exception: Unsupported value type System.Boolean when referencing Azure Storage resource #10432

Description

  • Is there an existing issue for this?

    • I have searched the existing issues
  • Describe the bug
    A NotSupportedException is thrown when referencing Azure Storage resources in an Aspire distributed app scenario. The error indicates "Unsupported value type System.Boolean" from AzureResourcePreparer.

  • Expected Behavior
    The application should run without throwing a NotSupportedException when referencing Azure Storage resources.

  • Steps To Reproduce
    Use the following repro code:

    using Aspire.Hosting.Yarp;
    using Aspire.Hosting.Yarp.Transforms;
    using Yarp.ReverseProxy.Configuration;
    
    var builder = DistributedApplication.CreateBuilder(args);
    
    builder.AddAzureStorage("storage");
    
    var apiService = builder.AddProject<Projects.aspirenew_ApiService>("apiservice")
        .WithHttpHealthCheck("/health");
    
    builder.AddProject<Projects.aspirenew_Web>("webfrontend")
        .WithExternalHttpEndpoints()
        .WithHttpHealthCheck("/health")
        .WithReference(apiService)
        .WaitFor(apiService);
    
    builder.AddYarp("mobile-bff")
        .WithConfiguration(builder =>
        {
            builder.AddRoute("/catalog-api/api/catalog/items", apiService.GetEndpoint("http"))
                .WithMatchRouteQueryParameter([new () { Name = "api-version", Values = ["1.0", "1", "2.0"], Mode = QueryParameterMatchMode.Exact }])
                .WithTransformPathRemovePrefix("/catalog-api");
        });
    
    builder.Build().Run();
  • Exceptions (if any)

    Unhandled exception. System.AggregateException: One or more errors occurred. (Unsupported value type System.Boolean)
     ---> System.NotSupportedException: Unsupported value type System.Boolean
       at Aspire.Hosting.Azure.AzureResourcePreparer.ProcessAzureReferences(HashSet`1 azureReferences, Object value) in /_/src/Aspire.Hosting.Azure/AzureResourcePreparer.cs:line 463
       at Aspire.Hosting.Azure.AzureResourcePreparer.GetAzureReferences(IResource resource, CancellationToken cancellationToken) in /_/src/Aspire.Hosting.Azure/AzureResourcePreparer.cs:line 377
       at Aspire.Hosting.Azure.AzureResourcePreparer.BuildRoleAssignmentAnnotations(DistributedApplicationModel appModel, List`1 azureResources, AzureProvisioningOptions options, CancellationToken cancellationToken) in 
    /_/src/Aspire.Hosting.Azure/AzureResourcePreparer.cs:line 142
       at Aspire.Hosting.Azure.AzureResourcePreparer.BeforeStartAsync(DistributedApplicationModel appModel, CancellationToken cancellationToken) in /_/src/Aspire.Hosting.Azure/AzureResourcePreparer.cs:line 39
       at Aspire.Hosting.DistributedApplication.ExecuteBeforeStartHooksAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/DistributedApplication.cs:line 475
       at Aspire.Hosting.DistributedApplication.RunAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/DistributedApplication.cs:line 425
       --- End of inner exception stack trace ---
       at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
       at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
       at System.Threading.Tasks.Task.Wait()
       at Aspire.Hosting.DistributedApplication.Run() in /_/src/Aspire.Hosting/DistributedApplication.cs:line 456
       at Program.<Main>$(String[] args) in D:\DotNetTest\aspirenew\aspirenew.AppHost\AppHost.cs:line 26
    
  • .NET Version info

  • Anything else?

    • ASP.NET Core version:
    • .NET Aspire version (e.g. package versions):
    • The IDE (VS / VS Code / Rider / Other) you're running on, and its version (and any extension versions):

    Please investigate why referencing Azure Storage in this scenario triggers an unsupported value type exception and how to resolve it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-integrationsIssues pertaining to Aspire Integrations packagesyarp

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions