Audit.NET.AzureStorageTables
27.1.1
dotnet add package Audit.NET.AzureStorageTables --version 27.1.1
NuGet\Install-Package Audit.NET.AzureStorageTables -Version 27.1.1
<PackageReference Include="Audit.NET.AzureStorageTables" Version="27.1.1" />
paket add Audit.NET.AzureStorageTables --version 27.1.1
#r "nuget: Audit.NET.AzureStorageTables, 27.1.1"
// Install Audit.NET.AzureStorageTables as a Cake Addin #addin nuget:?package=Audit.NET.AzureStorageTables&version=27.1.1 // Install Audit.NET.AzureStorageTables as a Cake Tool #tool nuget:?package=Audit.NET.AzureStorageTables&version=27.1.1
Audit.NET.AzureStorageTables
Azure Storage Tables provider for Audit.NET library (An extensible framework to audit executing operations in .NET).
Store the audit events in an Azure Table Storage.
Install
NuGet Package To install the package run the following command on the Package Manager Console:
PM> Install-Package Audit.NET.AzureStorageTables
How it works
This library uses the Azure.Data.Tables API to store the Audit Events on Azure Table Storage. Please see the Audit.NET Readme.
Usage
Set the static Audit.Core.Configuration.DataProvider
property to an instance of AzureTableDataProvider
, or call the UseAzureTableStorage()
method on the fluent configuration. This should be done before any AuditScope
creation, i.e. during application startup.
The AzureTableDataProvider
constructor accepts a Action<AzureTableDataProviderConfigurator>
parameter to configure the provider.
For Example:
Audit.Core.Configuration.DataProvider = new AzureTableDataProvider(config => config...)
Or:
Audit.Core.Configuration.Setup()
.UseAzureTableStorage(config => config...)
Configuration
Connection options
The Azure Storage connection can be configured in three different ways:
ConnectionString(string)
: Specifies the connection string to connect to the Azure Table Storage.Endpoint(Uri, Credentials)
: Specifies the endpoint and optionally the credentials to use.TableClientFactory(Func<AuditEvent, TableClient>)
: Specifies a table client factory that returns theTableClient
to use for a given Audit Event.
Table options
TableName(string)
: Specifies the table name to use. Defaults toaudit
.TableName(Func<AuditEvent, string>)
: Specifies a function that returns the table name to use for a given Audit Event.ClientOptions(TableClientOptions)
: Specifies the Table Client Options to use when connecting to the Azure Table Storage.EntityMapper(Func<AuditEvent, ITableEntity>)
: Specifies how to map the AuditEvent to an Azure TableEntity object. By default, an instance ofAuditEventTableEntity
is used, which adds one column named "AuditEvent" containing the Audit Event JSON representation.EntityBuilder(Action<IAzureTableRowConfigurator>)
: Specifies how to dynamically create a Table Entity from the Audit Event. Use this method as an alternative toEntityMapper()
to build the columns dynamically (see next section).
Entity Builder options
PartitionKey(string)
: Specifies the partition key to use. Defaults to the name of the Audit Event type.PartitionKey(Func<AuditEvent, string>)
: Sets the partition key to use as a function of the Audit EventRowKey(string)
: Sets the row key to use as a function of the Audit Event. Default is a random Guid.Columns(Action<IAzureTableColumnsConfigurator>)
: Defines a configuration for the extra columns (properties) on the entity. Default is one column "AuditEvent" with the audit event JSON. (see next section).
Columns Builder options
FromDictionary(Func<AuditEvent, IDictionary<string, object>>)
: Sets the columns (properties) values from a dictionary of strings and objects. Key is the column name, Value is the column value. (Value must be of a simple type or convertible to string).FromObject(Func<AuditEvent, object>)
: Sets the columns (properties) values from an object or an anonymous object. The object properties Values must be of a simple type or convertible to string.
Configuration examples
Providing the Connection String and the Table name. Using the default entity mapping.
Audit.Core.Configuration.Setup() .UseAzureTableStorage(config => config .ConnectionString(Settings.ConnectionString) .TableName(Settings.TableName));
Providing the Endpoint with a shared key credential, using the Audit Event's EventType as the Table name.. Using the default entity mapping.
Audit.Core.Configuration.Setup() .UseAzureTableStorage(config => config .Endpoint(new Uri(Settings.TableEndpointUrl), new TableSharedKeyCredential(Settings.AccountName, Settings.AccountKey)) .TableName(auditEvent => auditEvent.EventType);
Providing a custom TableClient factory. Using the default entity mapping.
Audit.Core.Configuration.Setup() .UseAzureTableStorage(config => config .TableClientFactory(auditEvent => GetTableClient(auditEvent.EventType)));
A more complex scenario providing the Endpoint, Table name and custom Client Options. Configuring a custom entity mapping that uses the Event Type as the partition key, a random Guid as the Row Key and includes 4 extra columns.
Audit.Core.Configuration.Setup() .UseAzureTableStorage(config => config .Endpoint(new Uri(Settings.TableEndpointUrl)) .TableName(Settings.TableName) .ClientOptions(new TableClientOptions() { Retry = { MaxRetries = 66 } }) .EntityBuilder(builder => builder .PartitionKey(auditEvent => auditEvent.EventType) .RowKey(auditEvent => Guid.NewGuid().ToString("N")) .Columns(col => col .FromDictionary(auditEvent => new Dictionary<string, object>() { { "EventType", auditEvent.EventType }, { "UserName", auditEvent.Environment.UserName }, { "EventDuration", auditEvent.Duration }, { "Data", auditEvent.ToJson() } }))));
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 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. |
-
.NETStandard 2.0
- Audit.NET (>= 27.1.1)
- Azure.Data.Tables (>= 12.8.2)
-
net6.0
- Audit.NET (>= 27.1.1)
- Azure.Data.Tables (>= 12.8.2)
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 |
---|---|---|
27.1.1 | 260 | 10/28/2024 |
27.1.0 | 110 | 10/24/2024 |
27.0.3 | 1,278 | 9/25/2024 |
27.0.2 | 998 | 9/19/2024 |
27.0.1 | 520 | 9/4/2024 |
27.0.0 | 108 | 9/3/2024 |
26.0.1 | 932 | 8/22/2024 |
26.0.0 | 1,010 | 7/19/2024 |
25.0.7 | 2,074 | 7/4/2024 |
25.0.6 | 698 | 6/24/2024 |
25.0.5 | 135 | 6/18/2024 |
25.0.4 | 4,384 | 3/24/2024 |
25.0.3 | 151 | 3/13/2024 |
25.0.2 | 112 | 3/12/2024 |
25.0.1 | 1,208 | 2/28/2024 |
25.0.0 | 1,682 | 2/16/2024 |
24.0.1 | 150 | 2/12/2024 |
24.0.0 | 114 | 2/12/2024 |
23.0.0 | 7,438 | 12/14/2023 |
22.1.0 | 741 | 12/9/2023 |
22.0.2 | 156 | 12/1/2023 |
22.0.1 | 182 | 11/16/2023 |
22.0.0 | 2,371 | 11/14/2023 |
21.1.0 | 1,676 | 10/9/2023 |
21.0.4 | 948 | 9/15/2023 |
21.0.3 | 3,229 | 7/9/2023 |
21.0.2 | 182 | 7/6/2023 |
21.0.1 | 10,896 | 5/27/2023 |
21.0.0 | 805 | 4/15/2023 |
20.2.4 | 1,202 | 3/27/2023 |
20.2.3 | 238 | 3/17/2023 |
20.2.2 | 3,028 | 3/14/2023 |
20.2.1 | 247 | 3/11/2023 |
20.2.0 | 622 | 3/7/2023 |
20.1.6 | 1,691 | 2/23/2023 |
20.1.5 | 447 | 2/9/2023 |
20.1.4 | 366 | 1/28/2023 |
20.1.3 | 1,627 | 12/21/2022 |
20.1.2 | 11,179 | 12/14/2022 |
20.1.1 | 317 | 12/12/2022 |
20.1.0 | 418 | 12/4/2022 |
20.0.4 | 346 | 11/30/2022 |
20.0.3 | 1,486 | 10/28/2022 |
20.0.2 | 409 | 10/26/2022 |
20.0.1 | 978 | 10/21/2022 |
20.0.0 | 555 | 10/1/2022 |
19.4.1 | 2,563 | 9/10/2022 |