Azure.AI.AnomalyDetector 3.0.0-preview.7

The ID prefix of this package has been reserved for one of the owners of this package by Prefix Reserved
This is a prerelease version of Azure.AI.AnomalyDetector.
dotnet add package Azure.AI.AnomalyDetector --version 3.0.0-preview.7
NuGet\Install-Package Azure.AI.AnomalyDetector -Version 3.0.0-preview.7
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="Azure.AI.AnomalyDetector" Version="3.0.0-preview.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Azure.AI.AnomalyDetector --version 3.0.0-preview.7
#r "nuget: Azure.AI.AnomalyDetector, 3.0.0-preview.7"
#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.
// Install Azure.AI.AnomalyDetector as a Cake Addin
#addin nuget:?package=Azure.AI.AnomalyDetector&version=3.0.0-preview.7&prerelease

// Install Azure.AI.AnomalyDetector as a Cake Tool
#tool nuget:?package=Azure.AI.AnomalyDetector&version=3.0.0-preview.7&prerelease

Azure Cognitive Services Anomaly Detector client library for .NET

Anomaly Detector is an AI service with a set of APIs, which enables you to monitor and detect anomalies in your time series data with little machine learning (ML) knowledge, either batch validation or real-time inference.

Source code | Package (NuGet) | API reference documentation | Product documentation

Getting started


  • You need an Azure subscription to use this package.
  • An existing Cognitive Services Anomaly Detector instance.

Install the package

Install the Azure Anomaly Detector client library for .NET with NuGet:

dotnet add package Azure.AI.AnomalyDetector --prerelease

This table shows the relationship between SDK versions and supported API versions of the service:

SDK version Supported API version of service
3.0.0-preview.6 1.1
3.0.0-preview.4, 3.0.0-preview.5 1.1-preview-1
3.0.0-beta.3 1.1-preview
3.0.0-preview.1, 3.0.0-preview.2 1.0

Authenticate the client

You can find the endpoint for your Anomaly Detector service resource using the Azure Portal or Azure CLI:

# Get the endpoint for the Anomaly Detector service resource
az cognitiveservices account show --name "resource-name" --resource-group "resource-group-name" --query "properties.endpoint"
Get the API Key

You can get the API Key from the Anomaly Detector service resource in the Azure Portal. Alternatively, you can use Azure CLI snippet below to get the API key of your resource.

az cognitiveservices account keys list --resource-group <your-resource-group-name> --name <your-resource-name>
Create AnomalyDetectorClient with AzureKeyCredential

Once you have the value for the API key, create an AzureKeyCredential. With the endpoint and key credential, you can create the AnomalyDetectorClient:

string endpoint = "<endpoint>";
string apiKey = "<apiKey>";
var credential = new AzureKeyCredential(apiKey);
var client = new AnomalyDetectorClient(new Uri(endpoint), credential);

Key concepts

With the Anomaly Detector, you can either detect anomalies in one variable using Univariate Anomaly Detection, or detect anomalies in multiple variables with Multivariate Anomaly Detection.

Feature Description
Univariate Anomaly Detection Detect anomalies in one variable, like revenue, cost, etc. The model was selected automatically based on your data pattern.
Multivariate Anomaly Detection Detect anomalies in multiple variables with correlations, which are usually gathered from equipment or other complex system. The underlying model used is Graph attention network.

Univariate Anomaly Detection

The Univariate Anomaly Detection API enables you to monitor and detect abnormalities in your time series data without having to know machine learning. The algorithms adapt by automatically identifying and applying the best-fitting models to your data, regardless of industry, scenario, or data volume. Using your time series data, the API determines boundaries for anomaly detection, expected values, and which data points are anomalies.

Using the Anomaly Detector doesn't require any prior experience in machine learning, and the REST API enables you to easily integrate the service into your applications and processes.

With the Univariate Anomaly Detection, you can automatically detect anomalies throughout your time series data, or as they occur in real-time.

Feature Description
Streaming detection Detect anomalies in your streaming data by using previously seen data points to determine if your latest one is an anomaly. This operation generates a model using the data points you send, and determines if the target point is an anomaly. By calling the API with each new data point you generate, you can monitor your data as it's created.
Batch detection Use your time series to detect any anomalies that might exist throughout your data. This operation generates a model using your entire time series data, with each point analyzed with the same model.
Change points detection Use your time series to detect any trend change points that exist in your data. This operation generates a model using your entire time series data, with each point analyzed with the same model.

Multivariate Anomaly Detection

The Multivariate Anomaly Detection APIs further enable developers by easily integrating advanced AI for detecting anomalies from groups of metrics, without the need for machine learning knowledge or labeled data. Dependencies and inter-correlations between up to 300 different signals are now automatically counted as key factors. This new capability helps you to proactively protect your complex systems such as software applications, servers, factory machines, spacecraft, or even your business, from failures.

With the Multivariate Anomaly Detection, you can automatically detect anomalies throughout your time series data, or as they occur in real-time. There are three processes to use Multivariate Anomaly Detection.

  • Training: Use Train Model API to create and train a model, then use Get Model Status API to get the status and model metadata.
  • Inference:
    • Use Async Inference API to trigger an asynchronous inference process and use Get Inference results API to get detection results on a batch of data.
    • You could also use Sync Inference API to trigger a detection on one timestamp every time.
  • Other operations: List Model API and Delete Model API are supported in Multivariate Anomaly Detection model for model management.

Thread safety

We guarantee that all client instance methods are thread-safe and independent of each other (guideline). This ensures that the recommendation of reusing client instances is always safe, even across threads.

Additional concepts

Client options | Accessing the response | Long-running operations | Handling failures | Diagnostics | Mocking | Client lifetime


The following section provides several code snippets covering some of the most common Anomaly Detector service tasks, including:

Batch detection

Console.WriteLine("Detecting anomalies in the entire time series.");

    UnivariateEntireDetectionResult result = client.DetectUnivariateEntireSeries(request);

    bool hasAnomaly = false;
    for (int i = 0; i < request.Series.Count; ++i)
        if (result.IsAnomaly[i])
            Console.WriteLine($"An anomaly was detected at index: {i}.");
            hasAnomaly = true;
    if (!hasAnomaly)
        Console.WriteLine("No anomalies detected in the series.");
catch (RequestFailedException ex)
    Console.WriteLine($"Entire detection failed: {ex.Message}");
catch (Exception ex)
    Console.WriteLine($"Detection error. {ex.Message}");

Streaming Detection

Console.WriteLine("Detecting the anomaly status of the latest point in the series.");

    UnivariateLastDetectionResult result = client.DetectUnivariateLastPoint(request);

    if (result.IsAnomaly)
        Console.WriteLine("The latest point was detected as an anomaly.");
        Console.WriteLine("The latest point was not detected as an anomaly.");
catch (RequestFailedException ex)
    Console.WriteLine($"Last detection failed: {ex.Message}");
catch (Exception ex)
    Console.WriteLine($"Detection error. {ex.Message}");

Detect change points

Console.WriteLine("Detecting the change point in the series.");

UnivariateChangePointDetectionResult result = client.DetectUnivariateChangePoint(request);

if (result.IsChangePoint.Contains(true))
    Console.WriteLine("A change point was detected at index:");
    for (int i = 0; i < request.Series.Count; ++i)
        if (result.IsChangePoint[i])
            Console.Write(" ");
    Console.WriteLine("No change point detected in the series.");

Multivariate Anomaly Detection Sample

To see how to use Anomaly Detector library to conduct Multivariate Anomaly Detection, see this sample.


Setting up console logging

The simplest way to see the logs is to enable the console logging. To create an Azure SDK log listener that outputs messages to console use the AzureEventSourceListener.CreateConsoleLogger method.

// Setup a listener to monitor logged events.
using AzureEventSourceListener listener = AzureEventSourceListener.CreateConsoleLogger();

To learn more about other logging mechanisms see Diagnostics Samples.

Next steps

These code samples show common scenario operations with the Azure Anomaly Detector library. More samples can be found under the samples directory.

Additional documentation

For more extensive documentation on Azure Anomaly Detector, see the Anomaly Detector documentation on


This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
3.0.0-preview.7 2,057 5/9/2023
3.0.0-preview.6 2,068 12/9/2022
3.0.0-preview.5 3,127 1/21/2022
3.0.0-preview.4 151 1/17/2022
3.0.0-preview.3 1,422 4/16/2021
3.0.0-preview.2 1,344 9/3/2020
3.0.0-preview.1 288 8/25/2020