AzureStorageClient 1.3.2

dotnet add package AzureStorageClient --version 1.3.2
                    
NuGet\Install-Package AzureStorageClient -Version 1.3.2
                    
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="AzureStorageClient" Version="1.3.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AzureStorageClient" Version="1.3.2" />
                    
Directory.Packages.props
<PackageReference Include="AzureStorageClient" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AzureStorageClient --version 1.3.2
                    
#r "nuget: AzureStorageClient, 1.3.2"
                    
#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.
#:package AzureStorageClient@1.3.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AzureStorageClient&version=1.3.2
                    
Install as a Cake Addin
#tool nuget:?package=AzureStorageClient&version=1.3.2
                    
Install as a Cake Tool

Introduction

Project to handle all interaction between Data2Track applications and the Azure Storage service. With this class library it will be easier to mantain the code for Azure connections in other projects.

Requirements

Version 1.3.0 or higher
  • .NET 8.0 or higher
Version 1.2.0 to 1.2.4
  • .NET 8.0 or higher
Below version 1.2.0
  • .NET 7.0 or higher

Azure Storage service

The following Azure Storage services are supported in this project:

  • Azure Table Storage
  • Azure Blob Storage
  • Azure Queue Storage

Installation

This class library is made to make life easier in other projects. To implement this in another project the following steps are required

Version 1.3.0 and higher

  1. Install the nuget package

Go to the nuget package manager of the project and search for "AzureStorageClient"

  1. Set up the Program.cs

1 - Set up the accounts to use for your service client

For each client type that you require, you will have to set up the desired client in the Program.cs along with the profile that you want to link the account to.

Since this version caching is added to be able to keep using the same table client for the variable table names.

builder.Services.AddAzureClients(clientBuilder =>
{
    //Table client

    //IMPORTANT! Add the default, else the application will crash
    clientBuilder.AddTableServiceClient(new Uri($"https://{builder.Configuration["YOUR_TABLE_ACCOUNT"]}.table.core.windows.net"))
    .WithName("Default");

    clientBuilder.AddTableServiceClient(new Uri($"https://{builder.Configuration["YOUR_TABLE_ACCOUNT"]}.table.core.windows.net"))
    .WithName(StorageClientProfile.Production);

    //Queue client
    clientBuilder.AddQueueServiceClient(new Uri($"https://{builder.Configuration["YOUR_TABLE_ACCOUNT"]}.queue.core.windows.net"))
    .WithName(StorageClientProfile.Production);

    //Blob client
    clientBuilder.AddBlobServiceClient(new Uri($"https://{builder.Configuration["YOUR_TABLE_ACCOUNT"]}.blob.core.windows.net"))
    .WithName(StorageClientProfile.Production);
});

builder.Services.AddSingleton<ITableClientFactory, TableClientFactory>();
builder.Services.AddMemoryCache();

Version 1.2.0 to 1.2.4

  1. Install the nuget package

Go to the nuget package manager of the project and search for "AzureStorageClient"

  1. Set up the Program.cs

1 - Set up the accounts to use for your service client

For each client type that you require, you will have to set up the desired client in the Program.cs along with the profile that you want to link the account to.

builder.Services.AddAzureClients(clientBuilder =>
{
    //Table client
    clientBuilder.AddTableServiceClient(new Uri($"https://{builder.Configuration["YOUR_TABLE_ACCOUNT"]}.table.core.windows.net"))
    .WithName(StorageClientProfile.Production);

    //Queue client
    clientBuilder.AddQueueServiceClient(new Uri($"https://{builder.Configuration["YOUR_TABLE_ACCOUNT"]}.queue.core.windows.net"))
    .WithName(StorageClientProfile.Production);

    //Blob client
    clientBuilder.AddBlobServiceClient(new Uri($"https://{builder.Configuration["YOUR_TABLE_ACCOUNT"]}.blob.core.windows.net"))
    .WithName(StorageClientProfile.Production);
});

In this case the account name will be linked to the production storage client profile. The supported storage client profiles are:

  • StorageClientProfile.Production
  • StorageClientProfile.Test
  • StorageClientProfile.RawData

2 - Add the required services as scoped

The service that you want to use will have to be added as a scoped service to your Program.cs as well. The services that you can use are the following:

//Azure table services
services.AddScoped<IAzureTableService, AzureTableService>()

//Azure queue services
services.AddScoped<IAzureQueueService, AzureQueueService>()

//Azure blob services
services.AddScoped<IAzureBlobService, AzureBlobService>()
  1. Usage in your service

GetEntity()

public class YourService(IAzureTableService azureTableService)

public async Task<T?> GetEntity(string partitionKey, string rowKey, string tableName, CloudStorageEnvironment storageEnvironment)
{
    return await _azureTableService.GetEntity(partitionKey, rowKey, TableNameHelper.GetTableName(typeof(T), CloudStorageEnvironment.Production);
}

GetEntities() + GetEntitiesAsyncPageable() - response differs

public class YourService(IAzureTableService azureTableService)

public async Task<List<T>> GetEntities(string filter, string tableName, CloudStorageEnvironment storageEnvironment)
{
    return await azureTableService.GetEntities<T>(query, TableNameHelper.GetTableName(typeof(T), companyId), cloudStorageEnvironment);
}

The CloudStorageEnvironment is the environment you want to get your data from. This is linked to the StorageClientProfile that has been set up in the Program.cs.

The supported environments are:

  • CloudStorageEnvironment.Production
  • CloudStorageEnvironment.Test
  • CloudStorageEnvironment.RawData
  1. TableNameHelper

Table names are defined in the TableNameHelper method as follows:

public static class TableNameHelper
{
    private static readonly Dictionary<Type, string> TypeTableDictionary = new()
    {
        { typeof(RandomModel), "RandomTableName" }
    };

    public static string GetTableName(Type tableType)
    {
        return $"{TypeTableDictionary[tableType]}";
    }
}

Version 1.1 and lower

  1. Install the nuget package

Go to the nuget package manager of the project and search for "AzureStorageClient"

  1. User secrets

Add user secrets to the project. The following section should be included:

  "AzureConnectionConfiguration": {
    "ProductionConnectionString": "",
    "TestConnectionString": "",
    "RawDataConnectionString": ""
  }

if the project is gonna be deployed to a Function App its important to configure the application settings. This can be done the following way: click new application setting:

Name AzureConnectionConfiguration:TestConnectionString example

Value "connectionstring for the storage account"

This has to be handled different compared to the local developement. The reason for this is the way a production environment handles appsettings.

  1. Startup

To use the package in a Azure Function project (V4 isolated), the options must be loaded inside the ConfigureService method and the AzureTableService must be injected with dependency injection. See the following example

  services.AddOptions<AzureConnectionConfiguration>().Configure<IConfiguration>((settings, config) =>
  {
      config.GetSection("AzureConnectionConfiguration").Bind(settings);
  });
  services.AddScoped<IAzureTableService, AzureTableService>();
  1. Usage in service

To use the service(s) it first must be injected into the service/feature that wants to use Azure Storage services. See the following example.

using AzureStorageClient.Services.Interfaces;
using AzureStorageClient.Models;

private readonly IAzureTableService _azureTableService

public SomeClass(IAzureTableService azureTableService)
{
  _azureTableService = azureTableService;
}

public async Task<Entity> GetEntity()
{
  string filter = "PartitionKey eq 'SOME PARTITIONKEY' and RowKey eq 'SOME ROWKEY'";
  return await _azureTableService.GetEntity(filter, tableName, CloudStorageEnvironment.Production);
}
  1. Usage of the AzureTableService

To use the example from 4. it is required to have a class that repesents the object in the table. This class needs to extend from the class AzureTableEntity (which comes included in with this package in the AzureStorageClient.Models namespace).

public class SomeClass : AzureTableEntity
{

}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on AzureStorageClient:

Package Downloads
FleetControlIdConverter

Converter for ID's between FleetControl V1 and V2

D2TIndex

Package to get information from the index tables

D2tOdometer

Package Description

FleetControlLoggingService

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.2 463 11/12/2025
1.3.1 449 11/11/2025 1.3.1 is deprecated because it has critical bugs.
1.3.0 444 8/5/2025
1.2.4 298 4/18/2025
1.2.3 881 12/18/2024
1.2.2 563 11/21/2024
1.2.0 477 9/18/2024
1.1.2 2,053 12/21/2023
1.1.1 829 4/18/2023
1.1.0 388 4/3/2023
1.0.14 589 2/7/2023
1.0.13 351 2/7/2023
1.0.12 601 11/30/2022
1.0.11 752 8/4/2022
1.0.10 506 8/4/2022
1.0.9 638 7/5/2022
1.0.8 519 7/5/2022
1.0.7 520 7/5/2022
1.0.6 541 7/4/2022
1.0.0-build 190 11/30/2022
Loading failed