Soenneker.Alerter.Util 11.0.1161

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

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Alerter.Util

A single application-facing abstraction for logging an alert, sending it to a Microsoft Teams channel, and optionally copying it to a support email address.

IAlerter is useful when application code should describe the alert without depending directly on the Teams and email delivery services. It includes convenience methods for the common error and notification cases, plus a method that accepts any LogLevel.

Installation

dotnet add package Soenneker.Alerter.Util

Registration

using Soenneker.Alerter.Util.Registrars;

builder.Services.AddAlerterAsSingleton();

For applications that keep notification dependencies scoped:

builder.Services.AddAlerterAsScoped();

The registrar also adds the required IMsTeamsUtil and IEmailSupportUtil dependency graphs with the matching lifetime. IAlerter uses TryAdd, so an implementation registered earlier by the application is preserved.

Send alerts

Inject IAlerter into the service that detects the condition:

using Soenneker.Alerter.Util.Abstract;

public sealed class ImportMonitor
{
    private readonly IAlerter _alerter;

    public ImportMonitor(IAlerter alerter)
    {
        _alerter = alerter;
    }

    public ValueTask ReportFailure(
        string importId,
        CancellationToken cancellationToken)
    {
        return _alerter.Error(
            subject: $"Import {importId} failed",
            message: "The source file could not be processed. Review the worker logs.",
            channel: "DataImports",
            includeEmail: true,
            cancellationToken: cancellationToken);
    }
}

For an informational message, Notify uses LogLevel.Information and defaults to the Notifications Teams channel:

await alerter.Notify(
    subject: "Catalog import complete",
    message: "2,418 products were updated.",
    cancellationToken: cancellationToken);

Use Send when the severity and channel are selected at runtime:

using Microsoft.Extensions.Logging;

await alerter.Send(
    subject: "Queue depth warning",
    message: "The billing queue has exceeded 10,000 messages.",
    level: LogLevel.Warning,
    channel: "Operations",
    cancellationToken: cancellationToken);

Delivery behavior

Every call performs these operations in order:

  1. Logs the message through ILogger<Alerter> at the selected level.
  2. Sends the subject and message to the selected Teams channel.
  3. When includeEmail is true, sends the same subject and message through the support email service.

Email delivery occurs only after Teams delivery completes successfully. If the Teams operation throws or is cancelled, the email operation is not attempted. The methods do not swallow delivery exceptions, so callers can retry, record a failure, or allow the exception to propagate according to application policy.

The default values are:

Method Log level Teams channel Email
Error Error Errors Disabled
Notify Information Notifications Disabled
Send Error Errors Disabled

Configuration

Teams delivery is provided by Soenneker.MsTeams.Util, and email delivery is provided by Soenneker.Email.Support. Configure both underlying services before sending alerts.

At minimum, Teams channel enablement is read from the channel name passed to IAlerter:

{
  "Environment": "Production",
  "MsTeams": {
    "DataImports": {
      "Enabled": true
    },
    "Notifications": {
      "Enabled": true
    },
    "Errors": {
      "Enabled": true
    }
  },
  "Email": {
    "SupportAddress": "support@example.com"
  }
}

Email:SupportAddress is required only when email delivery is used, but the email dependency must still be resolvable because it is injected into Alerter. See the underlying packages for their transport-specific configuration, including Teams immediate-versus-queued delivery and email dispatching.

API

Method Purpose
Error(subject, message, channel, includeEmail, cancellationToken) Sends an error-level alert; defaults to the Errors channel.
Notify(subject, message, channel, includeEmail, cancellationToken) Sends an information-level alert; defaults to the Notifications channel.
Send(subject, message, level, channel, includeEmail, cancellationToken) Sends an alert with explicit severity and routing.
AddAlerterAsSingleton() Registers the alerter and its notification dependencies as singletons.
AddAlerterAsScoped() Registers the alerter and its notification dependencies as scoped services.
Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
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
11.0.1161 0 11/15/2026
11.0.1160 0 11/15/2026
11.0.1159 45 11/14/2026
11.0.1158 74 11/12/2026
11.0.1157 61 11/12/2026
11.0.1156 46 11/12/2026
11.0.1155 59 11/12/2026
11.0.1154 99 11/12/2026
11.0.1153 71 11/11/2026
11.0.1152 74 11/11/2026
11.0.1151 80 11/11/2026
11.0.1150 73 11/11/2026
11.0.1149 77 11/11/2026
11.0.1148 73 11/11/2026
11.0.1147 79 11/11/2026
11.0.1146 72 11/11/2026
11.0.1144 92 11/11/2026
11.0.1143 84 11/11/2026
11.0.1142 409 11/4/2026
11.0.1141 104 11/4/2026
Loading failed

Update dependency Soenneker.MsTeams.Util to 11.0.1367 (#1673)