Audit.NET.AzureCosmos
27.3.1
See the version list below for details.
dotnet add package Audit.NET.AzureCosmos --version 27.3.1
NuGet\Install-Package Audit.NET.AzureCosmos -Version 27.3.1
<PackageReference Include="Audit.NET.AzureCosmos" Version="27.3.1" />
paket add Audit.NET.AzureCosmos --version 27.3.1
#r "nuget: Audit.NET.AzureCosmos, 27.3.1"
// Install Audit.NET.AzureCosmos as a Cake Addin #addin nuget:?package=Audit.NET.AzureCosmos&version=27.3.1 // Install Audit.NET.AzureCosmos as a Cake Tool #tool nuget:?package=Audit.NET.AzureCosmos&version=27.3.1
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
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 | Versions 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. |
-
.NETFramework 4.6.2
- Audit.NET (>= 27.3.1)
- Audit.NET.JsonNewtonsoftAdapter (>= 27.3.1)
- Microsoft.Azure.DocumentDB (>= 2.20.0)
-
.NETStandard 2.0
- Audit.NET (>= 27.3.1)
- Microsoft.Azure.Cosmos (>= 3.46.0)
-
net6.0
- Audit.NET (>= 27.3.1)
- Microsoft.Azure.Cosmos (>= 3.46.0)
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 | 135 | 12/11/2024 |
27.3.1 | 255 | 12/10/2024 |
27.3.0 | 142 | 12/8/2024 |
27.2.0 | 1,527 | 11/23/2024 |
27.1.1 | 2,991 | 10/28/2024 |
27.1.0 | 102 | 10/24/2024 |
27.0.3 | 2,689 | 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 | 299 | 8/22/2024 |
26.0.0 | 2,268 | 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,536 | 3/24/2024 |
25.0.3 | 253 | 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 | 190 | 2/12/2024 |
24.0.0 | 118 | 2/12/2024 |
23.0.0 | 5,307 | 12/14/2023 |
22.1.0 | 152 | 12/9/2023 |
22.0.2 | 1,281 | 12/1/2023 |
22.0.1 | 1,443 | 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 | 4,988 | 2/9/2023 |
20.1.4 | 10,253 | 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 | 46,943 | 10/28/2022 |
20.0.2 | 7,432 | 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,733 | 9/2/2022 |
19.3.0 | 1,455 | 8/23/2022 |
19.2.2 | 1,222 | 8/11/2022 |
19.2.1 | 10,912 | 8/6/2022 |
19.2.0 | 12,729 | 7/24/2022 |
19.1.4 | 46,399 | 5/23/2022 |
19.1.3 | 558 | 5/22/2022 |
19.1.2 | 693 | 5/18/2022 |
19.1.1 | 7,976 | 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,438 | 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,980 | 6/16/2021 |
17.0.6 | 535 | 6/5/2021 |
17.0.5 | 510 | 5/28/2021 |
17.0.4 | 1,074 | 5/4/2021 |
17.0.3 | 518 | 5/1/2021 |
17.0.2 | 514 | 4/22/2021 |