Package reference page maintained from the source documentation in src/HealthChecks.Gcp.CloudStorage.
Google Cloud Storage Health Check
This health check verifies the ability to communicate with Google Cloud Storage. It uses the provided StorageClient to list buckets for a project or fetch metadata for a configured bucket.
Defaults
By default, the StorageClient instance is resolved from the service provider. Configure either ProjectId for a service-level check or BucketName for a bucket-level check.
using Google.Cloud.Storage.V1;
using HealthChecks.Gcp.CloudStorage;
void ConfigureServices(IServiceCollection services)
{
services.AddSingleton(_ => StorageClient.Create());
services
.AddHealthChecks()
.AddCloudStorage(optionsFactory: _ => new CloudStorageHealthCheckOptions
{
ProjectId = "my-gcp-project"
});
}
Bucket check
When BucketName is set, the health check fetches that bucket's metadata. BucketName takes precedence over ProjectId when both values are configured.
using Google.Cloud.Storage.V1;
using HealthChecks.Gcp.CloudStorage;
void ConfigureServices(IServiceCollection services)
{
services.AddSingleton(_ => StorageClient.Create());
services
.AddHealthChecks()
.AddCloudStorage(optionsFactory: _ => new CloudStorageHealthCheckOptions
{
BucketName = "my-bucket"
});
}
Customization
You can additionally add the following parameters:
clientFactory: A factory method to provide aStorageClientinstance.optionsFactory: A factory method to provide aCloudStorageHealthCheckOptionsinstance. It allows specifyingProjectId,BucketName,GetBucketOptions, andListBucketsOptions.name: The health check name. The default isgcp_cloud_storage.failureStatus: TheHealthStatusthat 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.TimeSpanrepresenting the timeout of the check.