Audit.NET.AzureCosmos 25.0.7

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

// Install Audit.NET.AzureCosmos as a Cake Tool
#tool nuget:?package=Audit.NET.AzureCosmos&version=25.0.7                

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. 
.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
27.3.2 157 12/11/2024
27.3.1 421 12/10/2024
27.3.0 161 12/8/2024
27.2.0 1,610 11/23/2024
27.1.1 3,251 10/28/2024
27.1.0 102 10/24/2024
27.0.3 2,707 9/25/2024
27.0.2 359 9/19/2024
27.0.1 1,119 9/4/2024
27.0.0 194 9/3/2024
26.0.1 303 8/22/2024
26.0.0 2,286 7/19/2024
25.0.7 4,709 7/4/2024
25.0.6 2,028 6/24/2024
25.0.5 570 6/18/2024
25.0.4 23,662 3/24/2024
25.0.3 257 3/13/2024
25.0.2 214 3/12/2024
25.0.1 362 2/28/2024
25.0.0 3,092 2/16/2024
24.0.1 194 2/12/2024
24.0.0 122 2/12/2024
23.0.0 5,322 12/14/2023
22.1.0 152 12/9/2023
22.0.2 1,281 12/1/2023
22.0.1 1,450 11/16/2023
22.0.0 151 11/14/2023
21.1.0 3,059 10/9/2023
21.0.4 801 9/15/2023
21.0.3 12,387 7/9/2023
21.0.2 4,785 7/6/2023
21.0.1 1,203 5/27/2023
21.0.0 1,045 4/15/2023
20.2.4 9,253 3/27/2023
20.2.3 587 3/17/2023
20.2.2 322 3/14/2023
20.2.1 292 3/11/2023
20.2.0 419 3/7/2023
20.1.6 3,976 2/23/2023
20.1.5 5,028 2/9/2023
20.1.4 10,420 1/28/2023
20.1.3 971 12/21/2022
20.1.2 411 12/14/2022
20.1.1 471 12/12/2022
20.1.0 500 12/4/2022
20.0.4 450 11/30/2022
20.0.3 47,318 10/28/2022
20.0.2 7,469 10/26/2022
20.0.1 4,114 10/21/2022
20.0.0 1,564 10/1/2022
19.4.1 1,950 9/10/2022
19.4.0 1,748 9/2/2022
19.3.0 1,455 8/23/2022
19.2.2 1,222 8/11/2022
19.2.1 10,919 8/6/2022
19.2.0 12,731 7/24/2022
19.1.4 46,662 5/23/2022
19.1.3 558 5/22/2022
19.1.2 693 5/18/2022
19.1.1 7,996 4/28/2022
19.1.0 25,784 4/10/2022
19.0.7 8,771 3/13/2022
19.0.6 506 3/7/2022
19.0.5 5,600 1/28/2022
19.0.4 559 1/23/2022
19.0.3 4,632 12/14/2021
19.0.2 1,247 12/11/2021
19.0.1 10,348 11/20/2021
19.0.0 519 11/11/2021
19.0.0-rc.net60.2 181 9/26/2021
19.0.0-rc.net60.1 213 9/16/2021
18.1.6 4,023 9/26/2021
18.1.5 4,316 9/7/2021
18.1.4 416 9/6/2021
18.1.3 3,447 8/19/2021
18.1.2 584 8/8/2021
18.1.1 520 8/5/2021
18.1.0 558 8/1/2021
18.0.1 584 7/30/2021
18.0.0 537 7/26/2021
17.0.8 681 7/7/2021
17.0.7 7,982 6/16/2021
17.0.6 535 6/5/2021
17.0.5 510 5/28/2021
17.0.4 1,076 5/4/2021
17.0.3 518 5/1/2021
17.0.2 514 4/22/2021