microsoft / microsoft/aspire

AddAzureBlobClient ignores WithName when creating Health Check

Open
#11,152 1 comment 0 reactions 0 assignees View on GitHub
area-integrations
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

When registering a **BlobServiceClient** through **AddAzureBlobClient** and specifying the name under which the client should be registered using the **WithName** method, Health Checks seem to ignore the specified name. Calling the "/health-check" endpoint then throws an exception: _"InvalidOperationException: Unable to find client registration with type 'BlobServiceClient' and name 'Default'."_

### Expected Behavior

Upon specifying the name using the **WithName** method, Health Check should take the name into consideration and locate the **BlobServiceClient** assigned to that name instead of locating the one named "Default".

### Steps To Reproduce

To reproduce the error:
1. Clone [repository](https://github.com/SempiternalFlash/aspire-azureblobstorage-healthcheck-bug-report-project)
2. Run the program
3. Call the **/health-check**, base address for the endpoint of the api-service application can be acquired from Aspire dashboard
4. Exception should arise

To get working solution, before running the program, go to **Program.cs** and uncomment lines 15 and 23

### Exceptions (if any)

InvalidOperationException: Unable to find client registration with type 'BlobServiceClient' and name 'Default'.

### .NET Version info

Version: 9.0.8
Architecture: x64
Commit: aae90fa090

### Anything else?

Image

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.