Audit.NET.AzureStorageTables 27.0.0

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

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

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.1.1 96 10/28/2024
27.1.0 95 10/24/2024
27.0.3 906 9/25/2024
27.0.2 871 9/19/2024
27.0.1 465 9/4/2024
27.0.0 107 9/3/2024
26.0.1 622 8/22/2024
26.0.0 985 7/19/2024
25.0.7 1,788 7/4/2024
25.0.6 697 6/24/2024
25.0.5 134 6/18/2024
25.0.4 4,173 3/24/2024
25.0.3 150 3/13/2024
25.0.2 111 3/12/2024
25.0.1 1,170 2/28/2024
25.0.0 1,648 2/16/2024
24.0.1 149 2/12/2024
24.0.0 113 2/12/2024
23.0.0 7,136 12/14/2023
22.1.0 720 12/9/2023
22.0.2 155 12/1/2023
22.0.1 181 11/16/2023
22.0.0 2,314 11/14/2023
21.1.0 1,675 10/9/2023
21.0.4 946 9/15/2023
21.0.3 3,189 7/9/2023
21.0.2 181 7/6/2023
21.0.1 10,895 5/27/2023
21.0.0 804 4/15/2023
20.2.4 1,191 3/27/2023
20.2.3 237 3/17/2023
20.2.2 3,027 3/14/2023
20.2.1 246 3/11/2023
20.2.0 605 3/7/2023
20.1.6 1,686 2/23/2023
20.1.5 446 2/9/2023
20.1.4 363 1/28/2023
20.1.3 1,612 12/21/2022
20.1.2 11,178 12/14/2022
20.1.1 316 12/12/2022
20.1.0 417 12/4/2022
20.0.4 345 11/30/2022
20.0.3 1,485 10/28/2022
20.0.2 408 10/26/2022
20.0.1 975 10/21/2022
20.0.0 554 10/1/2022
19.4.1 2,562 9/10/2022