AspNetCore.HealthChecks.Azure.Storage.Blobs 9.0.0
Azure Blob Storage Health Check
This health check verifies the ability to communicate with Azure Blob Storage. It uses the provided BlobServiceClient to get first or configured blob container.
Defaults
By default, the BlobServiceClient
instance is resolved from service provider. AzureBlobStorageHealthCheckOptions
does not provide any specific container name, so the health check fetches just first container.
void Configure(IHealthChecksBuilder builder)
{
builder.Services.AddSingleton(sp => new BlobServiceClient(new Uri("azure-blob-storage-uri"), new DefaultAzureCredential()));
builder.AddHealthChecks().AddAzureBlobStorage();
}
Customization
You can additionally add the following parameters:
clientFactory
: A factory method to provideBlobServiceClient
instance.optionsFactory
: A factory method to provideAzureBlobStorageHealthCheckOptions
instance. It allows to specify the container name.name
: The health check name. The default isazure_blob_storage
.failureStatus
: TheHealthStatus
that should be reported when the health check fails. Default isHealthStatus.Unhealthy
.tags
: A list of tags that can be used to filter sets of health checks.timeout
: ASystem.TimeSpan
representing the timeout of the check.
void Configure(IHealthChecksBuilder builder)
{
builder.Services.AddSingleton(sp => new BlobServiceClient(new Uri("azure-blob-storage-uri"), new DefaultAzureCredential()));
builder.AddHealthChecks().AddAzureBlobStorage(
optionsFactory: sp => new AzureBlobStorageHealthCheckOptions()
{
ContainerName = "demo"
});
}
Breaking changes
In the prior releases, AzureBlobStorageHealthCheck
was a part of HealthChecks.AzureStorage
package. It had a dependency on not just Azure.Storage.Blobs
, but also Azure.Storage.Queues
and Azure.Storage.Files.Shares
. The packages have been split to avoid bringing unnecessary dependencies. Moreover, AzureBlobStorageHealthCheck
was letting the users specify how BlobServiceClient
should be created (from raw connection string or from endpoint uri and managed identity credentials), at a cost of maintaining an internal, static client instances cache. Now the type does not create client instances nor maintain an internal cache and it's the caller responsibility to provide the instance of BlobServiceClient
(please see #2040 for more details). Since Azure SDK recommends treating clients as singletons and client instances can be expensive to create, it's recommended to register a singleton factory method for Azure SDK clients. So the clients are created only when needed and once per whole application lifetime.
Showing the top 20 packages that depend on AspNetCore.HealthChecks.Azure.Storage.Blobs.
Packages | Downloads |
---|---|
Aspire.Hosting.Azure.Storage
Azure Storage resource types for .NET Aspire.
|
1 |
Aspire.Azure.Storage.Blobs
A client for Azure Blob Storage that integrates with Aspire, including health checks, logging and telemetry.
|
1 |
Aspire.Azure.Storage.Blobs
A client for Azure Blob Storage that integrates with Aspire, including health checks, logging and telemetry.
|
0 |
.NET 8.0
- Azure.Storage.Blobs (>= 12.19.1)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.11)
.NET Standard 2.0
- Azure.Storage.Blobs (>= 12.19.1)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.11)