UA.Azure.Storage
11.0.0
dotnet add package UA.Azure.Storage --version 11.0.0
NuGet\Install-Package UA.Azure.Storage -Version 11.0.0
<PackageReference Include="UA.Azure.Storage" Version="11.0.0" />
<PackageVersion Include="UA.Azure.Storage" Version="11.0.0" />
<PackageReference Include="UA.Azure.Storage" />
paket add UA.Azure.Storage --version 11.0.0
#r "nuget: UA.Azure.Storage, 11.0.0"
#:package UA.Azure.Storage@11.0.0
#addin nuget:?package=UA.Azure.Storage&version=11.0.0
#tool nuget:?package=UA.Azure.Storage&version=11.0.0
UA.Azure.Storage
UA.Azure.Storage is the Azure Storage package in the UA Devs stack. It uses a lightweight, REST-first programming model built on UA.Tenet agents: you send request models to Blob, Queue, and Table agents, and you get back StorageResponse so you can inspect headers, payloads, and status codes directly.
Why this package exists
Use UA.Azure.Storage when you want:
- one lightweight package for Blob, Queue, and Table storage operations
- direct control over Azure Storage REST behavior without the full Azure SDK surface
- stream-first blob upload and download flows
- explicit metadata, request ID, lease, tag, and OData query control
- an API style that fits naturally into Tenet services and agents
Package characteristics
- Targets
.NET 10and.NET 11. - Depends on
UA.Tenetand signs Azure Storage requests from a connection string. - Uses request models such as
BlobRequest,ContainerRequest,QueueRequest,MessageRequest,TableRequest, andEntityRequest. - Returns
StorageResponse, which exposes status code, headers, request metadata, and typed helpers such asReadStream(),ReadString(),ReadJson<T>(), andReadXml<T>().
Programming model
UA.Azure.Storage does not try to hide the transport. Each agent issues Azure Storage REST calls and returns a StorageResponse that you can inspect or deserialize as needed.
using UA.Azure.Storage.Blob;
using UA.Azure.Storage.Internals.Models;
BlobAgent blobs = new(connectionString, autoAssignRequestId: true);
using StorageResponse response = await blobs.GetBlob(("documents", "invoice.pdf"));
if (!response.IsSuccessStatusCode)
throw new InvalidOperationException((await response.ReadError())?.Message);
await using Stream payload = await response.ReadStream();
Useful shorthand conversions are built into the current request model set:
ContainerRequest,QueueRequest, andTableRequestcan be created from stringsBlobRequestcan be created from(containerName, blobName)tuplesMessageItem.DecodedTextexposes queue message text after Base64 decoding
Current agent surface
| Agent | Best current operations | Notes |
|---|---|---|
BlobAgent |
Service properties and stats, preflight, container create, delete, existence, properties, lease, ACL and metadata, container and blob listing, blob put (block, empty page and empty append blobs), get, delete, existence, properties, metadata, tags, tier, expiry, snapshot, undelete, lease, copy, incremental copy, abort copy, block, page and append-block uploads, block lists and page ranges, query contents, find by tags, and service SAS URIs (GetUploadUri, GetDownloadUri) |
Blob names are passed unencoded and URL-encoded per path segment. Some operations read options from BlobRequest.Metadata (for example lease-action, latest, blockid or encryption-scope); those option keys are never sent as x-ms-meta-* metadata. GetBlob streams its content, so dispose the response after reading it. CopyBlob sends ifModifiedSince and eTag as source conditions (x-ms-source-if-modified-since, x-ms-source-if-match). PutPageBlob accepts only the premium page blob tiers BlobAccessTier.P4 to P80. PutPage buffers a non-seekable content stream to send its exact length |
QueueAgent |
Queue create or delete or list, ACL and metadata reads and writes, message create or delete or list or update or clear, and account-level service calls | Message bodies are Base64-encoded (UTF-8) on create and update without modifying the MessageItem. Deserialize MessageList and read MessageItem.DecodedText on the way back. Getting messages without a positive visibility timeout uses the 30 seconds service default |
TableAgent |
Table create or delete or query, ACL reads and writes, service properties, entity create or update or delete or merge or upsert or query, and batch execution | Batch() emits IAsyncEnumerable<StorageResponse> with one entity group transaction of at most 100 operations per table. Update, merge and delete (single or batched) require an existing entity (If-Match: *, or the entity ETag: ifMatch for single merge and delete, TableAgent.ETag for batched operations); use the upsert operations to insert. Entity keys are escaped in the URI, long values are sent as Edm.Int64 (a ulong above long.MaxValue as the nearest Edm.Double, since Edm.Int64 is signed) and floating-point values as Edm.Double, and object and array values are serialized as JSON text. Use ODataQuery.Page(...) and ODataQuery.PageTables(...) with the x-ms-continuation-* response headers to read the next page |
Installation
dotnet add package UA.Azure.Storage
Quick start
Blob upload and download
using UA.Azure.Storage.Blob;
using UA.Azure.Storage.Blob.Models;
using UA.Azure.Storage.Internals.Models;
BlobAgent blobs = new(connectionString, autoAssignRequestId: true);
await blobs.CreateContainer("documents");
await using FileStream file = File.OpenRead("invoice.pdf");
using StorageResponse upload = await blobs.PutBlob(new BlobRequest
{
Container = "documents",
Name = "invoice.pdf",
Content = file,
MimeType = "application/pdf"
});
using StorageResponse download = await blobs.GetBlob(("documents", "invoice.pdf"));
await using Stream payload = await download.ReadStream();
Queue create, send, and peek
using UA.Azure.Storage.Internals.Models;
using UA.Azure.Storage.Queue;
using UA.Azure.Storage.Queue.Models;
QueueAgent queues = new(connectionString, autoAssignRequestId: true);
await queues.Create("processing-queue");
using StorageResponse send = await queues.Create(
new MessageRequest("processing-queue"),
new MessageItem { RawText = "Process order #12345" });
using StorageResponse peek = await queues.List(
new MessageRequest("processing-queue"),
maxResults: 5,
isPeekOnly: true);
MessageList? messages = await peek.ReadXml<MessageList>();
foreach (MessageItem message in messages?.Items ?? [])
{
Console.WriteLine(message.DecodedText);
}
Table upsert and query
using UA.Azure.Storage.Internals;
using UA.Azure.Storage.Internals.Models;
using UA.Azure.Storage.Table;
using UA.Azure.Storage.Table.Models;
using UA.Tenet.Collections;
TableAgent tables = new(connectionString, autoAssignRequestId: true);
await tables.Create("Customers");
Any<object> customer = new()
{
[TableAgent.PartitionKey] = "ES",
[TableAgent.RowKey] = "customer-001",
["Name"] = "John Doe",
["Email"] = "john@example.com"
};
await tables.ReplaceUpsert(new EntityRequest("Customers", "ES", "customer-001"), customer);
ODataQuery query = new ODataQuery()
.Select(["Name", "Email"])
.And(TableAgent.PartitionKey, ODataOperator.Equal, "ES")
.Top(100);
using StorageResponse response = await tables.Query(
new EntityRequest("Customers"),
query,
includeMetadata: true);
string json = await response.ReadString();
Configuration and dependency injection
Using a connection string
string connectionString = configuration.GetConnectionString("AzureStorage")
?? throw new InvalidOperationException("Missing AzureStorage connection string.");
BlobAgent blobs = new(connectionString, autoAssignRequestId: true);
Registering agents in DI
builder.Services.AddSingleton(sp =>
new BlobAgent(builder.Configuration.GetConnectionString("AzureStorage")!, autoAssignRequestId: true));
builder.Services.AddSingleton(sp =>
new QueueAgent(builder.Configuration.GetConnectionString("AzureStorage")!, autoAssignRequestId: true));
builder.Services.AddSingleton(sp =>
new TableAgent(builder.Configuration.GetConnectionString("AzureStorage")!, autoAssignRequestId: true));
Important notes
- Agents derive their base URLs and request signing from the connection string, so
AccountNameandAccountKeymust be present.BlobEndpoint,QueueEndpointandTableEndpointoverride the host-style endpoint, which enables path-style endpoints such as Azurite. - Blob and Queue requests are signed with Shared Key and Table requests with Shared Key Lite.
GetServiceStats()targets the read-access secondary endpoint (SecondaryBaseUrl), taken from{Service}SecondaryEndpointor derived from the primary endpoint ({account}-secondary).PreflightRequest(origin, method, requestHeaders, resourcePath)sends an anonymous CORS preflight with the requiredOriginandAccess-Control-Request-*headers.SetAcl(...)/SetContainerAcl(...)accept up to fiveSignedIdentifierstored access policies (an empty list clears them); read Get ACL responses withReadXml<SignedIdentifierList>().Read*methods return empty values for unsuccessful responses; useStorageResponse.ErrorCode(x-ms-error-code) andReadError()(code, message and raw XML/JSON body) instead.- Set
RetryOptionson an agent to opt in to retries of transient failures (network errors and 408, 429, 500, 502, 503, 504) with exponential backoff. Streamed blob uploads are sent once. - Queue message time-to-live accepts any positive number of seconds or -1 (never expires).
StorageResponseisIDisposable. Dispose it after consuming the content stream or body.- Queue messages are Base64-encoded on send. Use
MessageItem.DecodedTextafter deserializing the response payload. TableAgent.Batch()sends one entity group transaction per table and group of 100 operations, and yields oneStorageResponseper submitted batch. An update, merge or delete entity that carriesTableAgent.ETag(odata.etag) sends that value as itsIf-Matchinstead of*; a mismatch fails the change set with412 Precondition Failedfor that operation. The key is never stored as a property.- Table entity request payloads normalize object and array values to JSON text and add
@odata.typeannotations forEdm.Int64andEdm.Doublevalues so the REST payload uses Azure Table-compatible value shapes. ODataQueryquotes string literals (doubling'), keeps numeric and boolean literals unquoted, rejects property names that are not identifiers, and throws when a filter exceeds the service limit of 15 comparisons. Conditions the Table service cannot express (Exists,Length, non-prefixLike) are widened so no matching entity is missed; re-check them on the client when exact results are required.- This package is a lightweight REST wrapper, not a full replacement for the Azure SDK.
Documentation
For broader documentation and Azure protocol details, see:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. net11.0 is compatible. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
See https://docs.uadevs.org/azure-storage/release-notes for release notes and documentation.