Cross.WebHost.AvailabilityCheck 1.0.0

dotnet add package Cross.WebHost.AvailabilityCheck --version 1.0.0
                    
NuGet\Install-Package Cross.WebHost.AvailabilityCheck -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cross.WebHost.AvailabilityCheck" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cross.WebHost.AvailabilityCheck" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Cross.WebHost.AvailabilityCheck" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cross.WebHost.AvailabilityCheck --version 1.0.0
                    
#r "nuget: Cross.WebHost.AvailabilityCheck, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Cross.WebHost.AvailabilityCheck@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cross.WebHost.AvailabilityCheck&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Cross.WebHost.AvailabilityCheck&version=1.0.0
                    
Install as a Cake Tool

Nuget Documentation

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.

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 with nuget.org:

https://www.nuget.org/packages/Cross.WebHost.AvailabilityCheck

Installation

Install via NuGet Package Manager:

dotnet add package Cross.WebHost.AvailabilityCheck

Or via Package Manager Console:

Install-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: http://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"
    }
  }
}

Issues and Pull Request

Contribution is welcomed. If you would like to provide a PR please add some testing.

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Roadmap

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0.0 134 6/24/2025

Initial version.