Cross.WebHost.AvailabilityCheck
1.1.0
dotnet add package Cross.WebHost.AvailabilityCheck --version 1.1.0
NuGet\Install-Package Cross.WebHost.AvailabilityCheck -Version 1.1.0
<PackageReference Include="Cross.WebHost.AvailabilityCheck" Version="1.1.0" />
<PackageVersion Include="Cross.WebHost.AvailabilityCheck" Version="1.1.0" />
<PackageReference Include="Cross.WebHost.AvailabilityCheck" />
paket add Cross.WebHost.AvailabilityCheck --version 1.1.0
#r "nuget: Cross.WebHost.AvailabilityCheck, 1.1.0"
#:package Cross.WebHost.AvailabilityCheck@1.1.0
#addin nuget:?package=Cross.WebHost.AvailabilityCheck&version=1.1.0
#tool nuget:?package=Cross.WebHost.AvailabilityCheck&version=1.1.0
Cross.WebHost.AvailabilityCheck
A lightweight .NET library for validating microservice dependencies during application startup. The library ensures that all required services are available before the main application begins its operation.
Supported frameworks: .NET 6, .NET 7, .NET 8, .NET 9, .NET 10
Features
- Asynchronous health checks for HTTP/HTTPS endpoints
- Configurable retry policies with customizable timeouts
- Support for custom port configurations
- Built-in logging for dependency validation process
- Cancellation support for health check operations
Purpose
Designed to prevent application startup failures due to unavailable dependencies by implementing a readiness probe pattern for microservice environments.
Install NuGet package
Install the Cross.WebHost.AvailabilityCheck NuGet package into your ASP.NET Core project:
Install-Package Cross.WebHost.AvailabilityCheck
or
dotnet add package Cross.WebHost.AvailabilityCheck
Usage
Basic Configuration
Add service availability check in your Program.cs or Startup.cs:
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// ...
var app = builder.Build();
// ...
// Configure service hosts to check
var hostsToCheck = new[]
{
"CheckServiceUrls:AuthService",
"CheckServiceUrls:UserService"
};
// Add availability check
AvailabilityHostsConfiguration.ConfigureAvailabilityHosts(
hostsToCheck,
builder.Configuration,
app.Logger,
timeoutInMs: 1500, // (Optional) Default: 1000 ms.
maxAttempts: 100 // (Optional) Default: 50 times.
);
app.Run();
}
}
Configuration in appsettings.json
{
"CheckServiceUrls": {
"AuthService": "https://auth-service:5001",
"UserService": "http://user-service:5002"
}
}
Supported URL Formats
The library supports various URL formats:
- HTTP URLs:
http://service-name:80 - HTTPS URLs:
https://service-name:443 - HTTP Default ports:
http://service-name(assumes port 80) - HTTPS Default ports:
https://service-name(assumes port 443) - Custom ports:
service-name:5000 - IP addresses:
192.168.1.100:5000
Logging
The library uses standard .NET logging mechanisms. Configure logging level in your appsettings.json:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Cross.WebHost.AvailabilityCheck": "Debug"
}
}
}
Testing
Run unit tests:
dotnet test Cross.WebHost.AvailabilityCheck.Tests/Cross.WebHost.AvailabilityCheck.Tests.csproj
Run unit tests with OpenCover coverage:
dotnet test Cross.WebHost.AvailabilityCheck.Tests/Cross.WebHost.AvailabilityCheck.Tests.csproj \
--collect:"XPlat Code Coverage" \
--results-directory ./TestResults \
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
Issues and Pull Request
Contribution is welcomed. If you would like to provide a PR please add some testing.
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Roadmap
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Configuration (>= 10.0.5)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.5)
- Microsoft.Extensions.Logging (>= 10.0.5)
-
net6.0
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.Logging (>= 8.0.1)
-
net7.0
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.Logging (>= 8.0.1)
-
net8.0
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.Logging (>= 8.0.1)
-
net9.0
- Microsoft.Extensions.Configuration (>= 9.0.14)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.14)
- Microsoft.Extensions.Logging (>= 9.0.14)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.0 | 43 | 3/27/2026 |
| 1.1.0-preview.6 | 38 | 3/27/2026 |
| 1.1.0-preview.5 | 40 | 3/27/2026 |
| 1.1.0-preview.4 | 43 | 3/27/2026 |
| 1.0.0 | 297 | 6/24/2025 |
- Added multi-target support: net6.0, net7.0, net8.0, net9.0, net10.0.
- Aligned package dependencies by target framework in project files and nuspec.
- Migrated tests to Cross.WebHost.AvailabilityCheck.Tests and expanded test coverage for host parsing and availability checks.
- Added framework-specific package content to nuspec (lib/net6.0 ... lib/net10.0).