Skip to content

Confusing error when adding BlobContainer and BlobService to same AzureStorage resource #10327

@davidfowl

Description

@davidfowl
  • I have searched the existing issues

Describe the bug
When using the Aspire builder API as follows:

var st = builder.AddAzureStorage("storage");
var blobContainer = st.AddBlobContainer("bblob");
var blob = st.AddBlobService();

Running aspire publish produces a crash with the following error:

👎  An error occurred while connecting to the app host. The app host possibly crashed before it was available: AppHost process has exited
unexpectedly. Use --debug to see more details..
Unhandled exception. Aspire.Hosting.DistributedApplicationException: Cannot add resource of type 'Aspire.Hosting.Azure.AzureBlobStorageResource'
with name 'storage-blobs' because resource of type 'Aspire.Hosting.Azure.AzureBlobStorageResource' with that name already exists. Resource names
are case-insensitive.
   at Aspire.Hosting.DistributedApplicationBuilder.AddResource[T](T resource) in /_/src/Aspire.Hosting/DistributedApplicationBuilder.cs:line 586
   at Aspire.Hosting.AzureStorageExtensions.AddBlobService(IResourceBuilder`1 builder, String name) in
/_/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs:line 358
   at Program.<Main>$(String[] args) in C:\dev\git\dogfood\MyApp1005\MyApp1005.AppHost\AppHost.cs:line 25

This is very confusing.

Expected Behavior
A clearer error message or prevention of duplicate resource creation when both AddBlobContainer and AddBlobService are called on the same AzureStorage resource.

Steps To Reproduce

  1. Use the Aspire builder as above.
  2. Run aspire publish.

Exceptions (if any)
See error output above.

Anything else?

  • Resource names appear to be case-insensitive.
  • No clear guidance on API usage that prevents this scenario.
  • Suggested fix: Improve error messaging to clarify the exact API misuse and/or prevent this scenario at build-time.

Metadata

Metadata

Assignees

Labels

area-integrationsIssues pertaining to Aspire Integrations packagesazure-storageIssues related to azure storage integration

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions