TGC.AzureTableStorage
0.5.0
See the version list below for details.
dotnet add package TGC.AzureTableStorage --version 0.5.0
NuGet\Install-Package TGC.AzureTableStorage -Version 0.5.0
<PackageReference Include="TGC.AzureTableStorage" Version="0.5.0" />
paket add TGC.AzureTableStorage --version 0.5.0
#r "nuget: TGC.AzureTableStorage, 0.5.0"
// Install TGC.AzureTableStorage as a Cake Addin #addin nuget:?package=TGC.AzureTableStorage&version=0.5.0 // Install TGC.AzureTableStorage as a Cake Tool #tool nuget:?package=TGC.AzureTableStorage&version=0.5.0
TGC.AzureTableStorage
Disclaimer: This library is still in alpha and is used on your own risk!
Using the library
Before doing anything code related, you'll need to configure your appsettings.
Create the following section (Ensure naming is correct):
"StorageConfiguration": {
"AccountConnectionString": "DefaultEndpointsProtocol=https;AccountName={StorageAccountName};AccountKey={AccountKey};EndpointSuffix=core.windows.net"
}
In order to use the library you will need to add the following extension methods on your IServiceCollection:
builder.Services.AddAzureTableStorage();
The method above takes care of reading configuration values and setting up context.
Disclaimer: If you are using Azure Function App, the current version does not support Microsoft.Extensions.Configuration.Abstractions which this method is dependent on. If so, you can use:
builder.Services.AddAzureTableStorage("YourConnectionString");
The library maps classes to individual tables in the Azure Storage Account. For each table you will need to define a related DTO. The definition requires adding a custom attribute and inherit from a specific class.
An example looks like this:
namespace Your.Namespace;
[TableItem("FooBars")]
internal class FooBarItem : AzureTableItem
{
public string Foo { get; set; }
public string Bar { get; set; }
}
Now, you can simply use the interface IAzureTableStorageRepository with any of your registered DTOs. The repositories are defined as unbound generics, meaning you can easily inject it with any type which inherits from ITableEntity (via AzureTableItem). Your IServiceProvider takes care of the rest:
namespace Your.Namespace;
public class Service
{
private readonly ILogger<Service> _logger;
private readonly IAzureTableStorageRepository<FooBarItem> _azureTableStorageRepository;
public Service(ILogger<Service> log, IAzureTableStorageRepository<FooBarItem> azureTableStorageRepository)
{
_logger = log;
_azureTableStorageRepository = azureTableStorageRepository;
}
}
Changelog
Patch notes ordered by newest change
0.3.1
Changed provision of TableClient to factory pattern and upgraded unit tests to .Net 8 due to .Net version mismatch.
0.3.0
Breaking change. Upgraded package and .Net version to .Net 8. Updated configuration flow for client library. Minor changes to interfaces.
0.2.0
Breaking change. Support for Azure Managed Identity and changed configuration type for public injection.
0.1.5
Updated versions of TGC.Configuration and TGC.CodingStandards.
0.1.4
Fixed bug with not defining RowKey
0.1.3
Enhanced unit tests and elobrated Readme.md
0.1.2
Added another way of configuring storage context with connectionstring directly
0.1.1
Fixed failing unit tests
0.1.0
Upgraded to .Net 7 and updated readme
0.0.3
First alpha-release
Product | Versions 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. |
-
net8.0
- Azure.Data.Tables (>= 12.8.3)
- Azure.Identity (>= 1.10.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- TGC.CSharpCodingStandards (>= 2.1.0)
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 |
---|---|---|
0.5.1 | 0 | 12/29/2024 |
0.5.0 | 36 | 12/28/2024 |
0.4.0 | 126 | 4/6/2024 |
0.3.0 | 137 | 3/17/2024 |
0.2.1 | 164 | 7/16/2023 |
0.2.0 | 163 | 7/16/2023 |
0.1.6 | 145 | 6/18/2023 |
0.1.5 | 143 | 5/29/2023 |
0.1.4 | 134 | 5/29/2023 |
0.1.3 | 127 | 5/29/2023 |
0.1.2 | 143 | 5/28/2023 |
0.1.1 | 131 | 5/28/2023 |
0.1.0 | 129 | 5/28/2023 |
0.0.3 | 171 | 4/23/2023 |
0.0.2 | 166 | 4/23/2023 |
0.0.1 | 172 | 4/23/2023 |