Audit.NET.AzureCosmos 27.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Audit.NET.AzureCosmos --version 27.3.0
                    
NuGet\Install-Package Audit.NET.AzureCosmos -Version 27.3.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="Audit.NET.AzureCosmos" Version="27.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Audit.NET.AzureCosmos" Version="27.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Audit.NET.AzureCosmos" />
                    
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 Audit.NET.AzureCosmos --version 27.3.0
                    
#r "nuget: Audit.NET.AzureCosmos, 27.3.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 Audit.NET.AzureCosmos@27.3.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=Audit.NET.AzureCosmos&version=27.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Audit.NET.AzureCosmos&version=27.3.0
                    
Install as a Cake Tool

Audit.NET.AzureCosmos

Azure Cosmos DB (Document DB SQL API) provider for Audit.NET library. (An extensible framework to audit executing operations in .NET)

Store the audit events in an Azure Cosmos DB collection, in JSON format.

Install

NuGet Package To install the package run the following command on the Package Manager Console:

PM> Install-Package Audit.NET.AzureCosmos

NuGet Status NuGet Count

Usage

Please see the Audit.NET Readme

Configuration

Set the static Audit.Core.Configuration.DataProvider property to set the Cosmos DB data provider, or use the UseAzureCosmos method on the fluent configuration. This should be done before any AuditScope creation, i.e. during application startup.

For example:

Audit.Core.Configuration.DataProvider = new Audit.AzureCosmos.Providers.AzureCosmosDataProvider(config => config
    .Endpoint("https://mycompany.documents.azure.com:443/")
    .AuthKey("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==")
    .Database("Audit")
    .Container("logs")
    .WithId(_ => Guid.NewGuid().ToString().ToUpper()));

Or by using the fluent configuration API:

Audit.Core.Configuration.Setup()
    .UseAzureCosmos(config => config
        .Endpoint("https://mycompany.documents.azure.com:443/")
        .AuthKey("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==")
        .Database("Audit")
        .Container("logs")
        .ClientOptions(options => { options.ConnectionMode = ConnectionMode.Gateway; }));

Provider options

Mandatory config with an Endpoint and an AuthKey:

  • Endpoint / EndpointBuilder: The Azure Cosmos endpoint URL.
  • AuthKey / AuthKeyBuilder: The Auth Key to use.

Or with a previously configured instance of DocumentClient/CosmosClient:

  • DocumentClient / CosmosClient: Sets an already configured document/cosmos client.

Container seetings:

  • Database / DatabaseBuilder: The audit database name.
  • Container / ContainerBuilder: The events container name.
  • WithId / IdBuilder: A func that returns the document id to use for a given audit event. By default it will generate a new random id.

Query events

This provider implements GetEvent and GetEventAsync methods to obtain an audit event by id and partition key. Note that if your container has a partition key defined, you need to provide both id and partition key:

var event = auditDataProvider.GetEvent(("eventId", "partitionValue"));

or using the overload on the concrete AzureCosmosDataProvider:

var event = azureCosmosDataProvider.GetEvent("eventId", "partitionValue");

The Azure Cosmos data provider also includes support for querying the events collection.

Use the QueryEvents() method on AzureCosmosDataProvider class to run LINQ queries against the audit events.

For example, to get the top 10 most time-consuming events for a specific machine:

IQueryable<AuditEvent> query = azureCosmosDataProvider.QueryEvents()
	.Where(ev => ev.Environment.MachineName == "HP")
	.OrderByDescending(ev => ev.Duration)
	.Take(10);

Also you can use the EnumerateEvents() method to run SQL-like queries. For example the previous query can be written as:

IEnumerable<AuditEvent> events = cosmosDbDataProvider.EnumerateEvents(
       @"SELECT TOP 10 * 
         FROM c 
         WHERE c.Environment.MachineName = 'HP' 
         ORDER BY c.Duration DESC");

This post contains information about the SQL query syntax supported by Azure Document DB.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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.  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. 
.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 is compatible.  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 (2)

Showing the top 2 NuGet packages that depend on Audit.NET.AzureCosmos:

Package Downloads
Solhigson.Framework.AzureCosmosDb

Azure Cosmos Db Client and NLog Target

AuditLogger

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
32.0.0 161 1/8/2026
31.3.3 546 12/31/2025
31.3.2 159 12/20/2025
31.3.1 832 12/9/2025
31.3.0 229 12/5/2025
31.2.0 473 11/27/2025
31.1.0 271 11/26/2025
31.0.2 4,944 10/2/2025
31.0.1 3,388 8/28/2025
31.0.0 613 8/22/2025
30.1.3 11,807 8/19/2025
30.1.2 276 8/14/2025
30.1.1 460 8/13/2025
30.0.2 7,289 6/26/2025
30.0.1 3,458 5/29/2025
30.0.0 324 5/27/2025
29.0.1 3,950 5/8/2025
29.0.0 1,653 5/6/2025
28.0.0 414 5/5/2025
27.5.3 1,645 4/23/2025
27.5.2 1,621 4/9/2025
27.5.1 385 4/4/2025
27.5.0 4,134 3/5/2025
27.4.1 5,866 2/9/2025
27.4.0 696 1/29/2025
27.3.3 5,897 1/21/2025
27.3.2 7,021 12/11/2024
27.3.1 2,444 12/10/2024
27.3.0 419 12/8/2024
27.2.0 2,962 11/23/2024
27.1.1 103,850 10/28/2024
27.1.0 285 10/24/2024
27.0.3 6,263 9/25/2024
27.0.2 550 9/19/2024
27.0.1 1,280 9/4/2024
27.0.0 389 9/3/2024
26.0.1 1,012 8/22/2024
26.0.0 3,160 7/19/2024
25.0.7 4,961 7/4/2024
25.0.6 2,194 6/24/2024
25.0.5 732 6/18/2024
25.0.4 37,869 3/24/2024
25.0.3 497 3/13/2024
25.0.2 368 3/12/2024
25.0.1 547 2/28/2024
25.0.0 3,369 2/16/2024
24.0.1 378 2/12/2024
24.0.0 264 2/12/2024
23.0.0 6,470 12/14/2023
22.1.0 299 12/9/2023
22.0.2 1,401 12/1/2023
22.0.1 3,174 11/16/2023
22.0.0 229 11/14/2023
21.1.0 3,172 10/9/2023
21.0.4 880 9/15/2023
21.0.3 12,524 7/9/2023
21.0.2 4,927 7/6/2023
21.0.1 1,376 5/27/2023
21.0.0 1,174 4/15/2023
20.2.4 9,508 3/27/2023
20.2.3 731 3/17/2023
20.2.2 466 3/14/2023
20.2.1 416 3/11/2023
20.2.0 605 3/7/2023
20.1.6 4,197 2/23/2023
20.1.5 5,188 2/9/2023
20.1.4 11,617 1/28/2023
20.1.3 1,090 12/21/2022
20.1.2 538 12/14/2022
20.1.1 612 12/12/2022
20.1.0 630 12/4/2022
20.0.4 613 11/30/2022
20.0.3 70,849 10/28/2022
20.0.2 10,464 10/26/2022
20.0.1 4,415 10/21/2022
20.0.0 1,750 10/1/2022
19.4.1 2,102 9/10/2022
19.4.0 2,647 9/2/2022
19.3.0 1,617 8/23/2022
19.2.2 1,374 8/11/2022
19.2.1 11,379 8/6/2022
19.2.0 13,142 7/24/2022
19.1.4 81,153 5/23/2022
19.1.3 745 5/22/2022
19.1.2 847 5/18/2022
19.1.1 8,333 4/28/2022
19.1.0 25,960 4/10/2022
19.0.7 10,317 3/13/2022
19.0.6 700 3/7/2022
19.0.5 5,825 1/28/2022
19.0.4 716 1/23/2022
19.0.3 4,828 12/14/2021
19.0.2 1,435 12/11/2021
19.0.1 10,554 11/20/2021
19.0.0 704 11/11/2021
19.0.0-rc.net60.2 319 9/26/2021
19.0.0-rc.net60.1 345 9/16/2021
18.1.6 4,755 9/26/2021
18.1.5 5,687 9/7/2021
18.1.4 592 9/6/2021
18.1.3 5,824 8/19/2021
18.1.2 884 8/8/2021
18.1.1 672 8/5/2021
18.1.0 743 8/1/2021
18.0.1 757 7/30/2021
18.0.0 724 7/26/2021
17.0.8 866 7/7/2021
17.0.7 8,231 6/16/2021
17.0.6 732 6/5/2021
17.0.5 697 5/28/2021
17.0.4 1,260 5/4/2021
17.0.3 700 5/1/2021
17.0.2 780 4/22/2021