Audit.NET.AzureStorageTables 27.3.1

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

// Install Audit.NET.AzureStorageTables as a Cake Tool
#tool nuget:?package=Audit.NET.AzureStorageTables&version=27.3.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

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
27.3.2 122 12/11/2024
27.3.1 81 12/10/2024
27.3.0 114 12/8/2024
27.2.0 465 11/23/2024
27.1.1 483 10/28/2024
27.1.0 123 10/24/2024
27.0.3 1,995 9/25/2024
27.0.2 1,046 9/19/2024
27.0.1 592 9/4/2024
27.0.0 115 9/3/2024
26.0.1 1,316 8/22/2024
26.0.0 1,023 7/19/2024
25.0.7 2,702 7/4/2024
25.0.6 707 6/24/2024
25.0.5 144 6/18/2024
25.0.4 5,059 3/24/2024
25.0.3 155 3/13/2024
25.0.2 116 3/12/2024
25.0.1 1,404 2/28/2024
25.0.0 1,869 2/16/2024
24.0.1 158 2/12/2024
24.0.0 122 2/12/2024
23.0.0 7,839 12/14/2023
22.1.0 813 12/9/2023
22.0.2 160 12/1/2023
22.0.1 186 11/16/2023
22.0.0 2,702 11/14/2023
21.1.0 1,681 10/9/2023
21.0.4 957 9/15/2023
21.0.3 3,377 7/9/2023
21.0.2 186 7/6/2023
21.0.1 10,900 5/27/2023
21.0.0 809 4/15/2023
20.2.4 1,286 3/27/2023
20.2.3 242 3/17/2023
20.2.2 3,032 3/14/2023
20.2.1 251 3/11/2023
20.2.0 648 3/7/2023
20.1.6 1,697 2/23/2023
20.1.5 451 2/9/2023
20.1.4 370 1/28/2023
20.1.3 1,661 12/21/2022
20.1.2 11,183 12/14/2022
20.1.1 321 12/12/2022
20.1.0 422 12/4/2022
20.0.4 352 11/30/2022
20.0.3 1,490 10/28/2022
20.0.2 413 10/26/2022
20.0.1 1,010 10/21/2022
20.0.0 559 10/1/2022
19.4.1 2,572 9/10/2022