No1.OpenSearchCommons 1.1.0

dotnet add package No1.OpenSearchCommons --version 1.1.0
                    
NuGet\Install-Package No1.OpenSearchCommons -Version 1.1.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="No1.OpenSearchCommons" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="No1.OpenSearchCommons" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="No1.OpenSearchCommons" />
                    
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 No1.OpenSearchCommons --version 1.1.0
                    
#r "nuget: No1.OpenSearchCommons, 1.1.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 No1.OpenSearchCommons@1.1.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=No1.OpenSearchCommons&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=No1.OpenSearchCommons&version=1.1.0
                    
Install as a Cake Tool

No1.OpenSearchCommons

Tools and libraries required by .NET applications to use OpenSearch

Contents

This library has two important classes:

  • OpenSearchHealthCheck can be added as health checker to asp.net health checks:
builder.Services
	.AddHealthChecks()
	.AddCheck<OpenSearchHealthCheck>("OpenSearch");
  • OpenSearchExtensions class has a helper method that registers specific http client for connecting to OpenSearch server. OpenSearch requires you to generate custom keys, certificates, pem files, ... to trust to clients.

After you created the keys, you can specify your client key and certificate files and also root certificate authority file in configuration file:

{
	"OpenSearchConfig": {
		"ClientCertificateFile": "/usr/share/opensearch/config/client.pem",
		"ClientPrivateKeyFile": "/usr/share/opensearch/config/client-key.pem",
		"RootCertificateAuthorityFile": "/usr/share/opensearch/config/root-ca.pem",
		"HealthUrl":  "https://[domain]:[port]/_cluster/health"
	}
}

Then get service by name (OpenSearchExtensions.OpenSearchKey):

public class OpenSearchHealthCheck(IHttpClientFactory factory) : IHealthCheck
{
	public HttpClient GetClient() {
		return  factory.CreateClient(OpenSearchExtensions.OpenSearchKey);
	}
}

Above HttpClient provides client certificate to the OpenSearch server and also verifies that the server has valid certificates. This HttpClient has been used for OpenSearchHealthCheck, but can be used elsewhere too.

You have problem in configuring OpenSearch? then read my another repo Boots.OpenSearchBoot

How to use?

Add below dependency:

dotnet package add No1.OpenSearchCommons

Then add below line in the Program.cs before building app:

using No1.OpenSearchCommons;
//...
builder.RegisterOpenSearchCertificateSignedHttpClient();

For adding OpenSearch to Health, add below code too:

builder.Services
	.AddHealthChecks()
	.AddCheck<OpenSearchHealthCheck>("OpenSearch");
Product Compatible and additional computed target framework versions.
.NET 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. 
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.1.0 344 6/22/2026
1.0.0 115 6/22/2026