NetEvolve.HealthChecks.Azure.ApplicationInsights
5.0.0
Prefix Reserved
dotnet add package NetEvolve.HealthChecks.Azure.ApplicationInsights --version 5.0.0
NuGet\Install-Package NetEvolve.HealthChecks.Azure.ApplicationInsights -Version 5.0.0
<PackageReference Include="NetEvolve.HealthChecks.Azure.ApplicationInsights" Version="5.0.0" />
<PackageVersion Include="NetEvolve.HealthChecks.Azure.ApplicationInsights" Version="5.0.0" />
<PackageReference Include="NetEvolve.HealthChecks.Azure.ApplicationInsights" />
paket add NetEvolve.HealthChecks.Azure.ApplicationInsights --version 5.0.0
#r "nuget: NetEvolve.HealthChecks.Azure.ApplicationInsights, 5.0.0"
#:package NetEvolve.HealthChecks.Azure.ApplicationInsights@5.0.0
#addin nuget:?package=NetEvolve.HealthChecks.Azure.ApplicationInsights&version=5.0.0
#tool nuget:?package=NetEvolve.HealthChecks.Azure.ApplicationInsights&version=5.0.0
NetEvolve.HealthChecks.Azure.ApplicationInsights
This package provides health checks for Azure Application Insights, allowing you to monitor the availability and connectivity of your telemetry tracking.
💡 This package is available for .NET 6.0 and later.
Installation
To use this package, you need to add the package to your project. You can do this by using the NuGet package manager or by using the dotnet CLI.
dotnet add package NetEvolve.HealthChecks.Azure.ApplicationInsights
Health Check - Azure Application Insights Availability
The health check checks the availability of Azure Application Insights by attempting to track a test telemetry event.
Usage
After adding the package, you need to import the namespace NetEvolve.HealthChecks.Azure.ApplicationInsights and add the health check to the service collection.
using NetEvolve.HealthChecks.Azure.ApplicationInsights;
Depending on the configuration approach, you can use two different approaches.
Parameters
name: The name of the health check. The name is used to identify the configuration object. It is required and must be unique within the application.options: The configuration options for the health check. If you don't provide any options, the health check will use the configuration based approach.tags: The tags for the health checks. The tagsazure,applicationinsights, andtelemetryare always used as default and combined with the user input. You can provide additional tags to group or filter the health checks.
Variant 1: Configuration based
The first approach is to use the configuration-based method. Therefore, you have to add the configuration section HealthChecks:ApplicationInsightsAvailability to your appsettings.json file.
var builder = services.AddHealthChecks();
builder.AddApplicationInsightsAvailability("<name>");
The configuration looks like this:
{
..., // other configuration
"HealthChecks": {
"ApplicationInsightsAvailability": {
"<name>": {
"ConnectionString": "<connection-string>", // required
"Mode": "<mode>", // required, to specify the client creation mode, either `ConnectionString`, `InstrumentationKey`, or `ServiceProvider`
"Timeout": "<timeout>" // optional, default is 100 milliseconds
}
}
}
}
Variant 2: Options based
The second approach is to use the options-based method. Therefore, you have to create an instance of ApplicationInsightsAvailabilityOptions and provide the configuration.
var builder = services.AddHealthChecks();
builder.AddApplicationInsightsAvailability("<name>", options =>
{
options.ConnectionString = "<connection-string>";
options.Mode = ApplicationInsightsClientCreationMode.ConnectionString;
...
options.Timeout = "<timeout>";
});
Client Creation Modes
The health check supports different modes for creating the Application Insights TelemetryClient:
ConnectionString
Use this mode when you have an Application Insights connection string.
builder.AddApplicationInsightsAvailability("<name>", options =>
{
options.Mode = ApplicationInsightsClientCreationMode.ConnectionString;
options.ConnectionString = "InstrumentationKey=12345678-1234-1234-1234-123456789abc;IngestionEndpoint=https://westus-0.in.applicationinsights.azure.com/";
});
Configuration:
{
"HealthChecks": {
"ApplicationInsightsAvailability": {
"<name>": {
"Mode": "ConnectionString",
"ConnectionString": "InstrumentationKey=12345678-1234-1234-1234-123456789abc;IngestionEndpoint=https://westus-0.in.applicationinsights.azure.com/"
}
}
}
}
InstrumentationKey
Use this mode when you have an Application Insights instrumentation key.
builder.AddApplicationInsightsAvailability("<name>", options =>
{
options.Mode = ApplicationInsightsClientCreationMode.InstrumentationKey;
options.InstrumentationKey = "12345678-1234-1234-1234-123456789abc";
});
Configuration:
{
"HealthChecks": {
"ApplicationInsightsAvailability": {
"<name>": {
"Mode": "InstrumentationKey",
"InstrumentationKey": "12345678-1234-1234-1234-123456789abc"
}
}
}
}
ServiceProvider
Use this mode when you have already registered a TelemetryClient in the service provider (e.g., using AddApplicationInsightsTelemetry()).
// First register Application Insights
builder.Services.AddApplicationInsightsTelemetry();
// Then add the health check
builder.AddApplicationInsightsAvailability("<name>", options =>
{
options.Mode = ApplicationInsightsClientCreationMode.ServiceProvider;
});
Configuration:
{
"HealthChecks": {
"ApplicationInsightsAvailability": {
"<name>": {
"Mode": "ServiceProvider"
}
}
}
}
💡 You can always provide tags to all health checks, for grouping or filtering.
var builder = services.AddHealthChecks();
builder.AddApplicationInsightsAvailability("<name>", options => ..., "custom", "azure");
License
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions 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 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
- Azure.Identity (>= 1.17.1)
- Microsoft.ApplicationInsights (>= 2.23.0)
- Microsoft.ApplicationInsights.AspNetCore (>= 2.23.0)
- NetEvolve.Extensions.Tasks (>= 1.3.74)
- System.Drawing.Common (>= 9.0.11)
-
net8.0
- Azure.Identity (>= 1.17.1)
- Microsoft.ApplicationInsights (>= 2.23.0)
- Microsoft.ApplicationInsights.AspNetCore (>= 2.23.0)
- NetEvolve.Extensions.Tasks (>= 1.3.74)
- System.Drawing.Common (>= 9.0.11)
-
net9.0
- Azure.Identity (>= 1.17.1)
- Microsoft.ApplicationInsights (>= 2.23.0)
- Microsoft.ApplicationInsights.AspNetCore (>= 2.23.0)
- NetEvolve.Extensions.Tasks (>= 1.3.74)
- System.Drawing.Common (>= 9.0.11)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on NetEvolve.HealthChecks.Azure.ApplicationInsights:
| Package | Downloads |
|---|---|
|
NetEvolve.HealthChecks.Azure
Contains HealthChecks for various Azure services. |
GitHub repositories
This package is not used by any popular GitHub repositories.