Audit.NET.AzureStorageTables 25.0.4

dotnet add package Audit.NET.AzureStorageTables --version 25.0.4
NuGet\Install-Package Audit.NET.AzureStorageTables -Version 25.0.4
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.AzureStorageTables" Version="25.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Audit.NET.AzureStorageTables --version 25.0.4
#r "nuget: Audit.NET.AzureStorageTables, 25.0.4"
#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.AzureStorageTables as a Cake Addin
#addin nuget:?package=Audit.NET.AzureStorageTables&version=25.0.4

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

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

NuGet Status NuGet Count

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 the TableClient to use for a given Audit Event.

Table options

  • TableName(string): Specifies the table name to use. Defaults to audit.
  • 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 of AuditEventTableEntity 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 to EntityMapper() 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 Event
  • RowKey(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 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. 
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
25.0.4 553 3/24/2024
25.0.3 117 3/13/2024
25.0.2 82 3/12/2024
25.0.1 262 2/28/2024
25.0.0 812 2/16/2024
24.0.1 118 2/12/2024
24.0.0 80 2/12/2024
23.0.0 2,840 12/14/2023
22.1.0 107 12/9/2023
22.0.2 128 12/1/2023
22.0.1 150 11/16/2023
22.0.0 1,061 11/14/2023
21.1.0 1,159 10/9/2023
21.0.4 904 9/15/2023
21.0.3 1,931 7/9/2023
21.0.2 148 7/6/2023
21.0.1 10,548 5/27/2023
21.0.0 780 4/15/2023
20.2.4 955 3/27/2023
20.2.3 211 3/17/2023
20.2.2 2,889 3/14/2023
20.2.1 235 3/11/2023
20.2.0 516 3/7/2023
20.1.6 1,534 2/23/2023
20.1.5 418 2/9/2023
20.1.4 335 1/28/2023
20.1.3 1,155 12/21/2022
20.1.2 11,130 12/14/2022
20.1.1 290 12/12/2022
20.1.0 388 12/4/2022
20.0.4 317 11/30/2022
20.0.3 1,324 10/28/2022
20.0.2 380 10/26/2022
20.0.1 865 10/21/2022
20.0.0 521 10/1/2022
19.4.1 2,512 9/10/2022