UA.Azure.Storage
4.9.3
dotnet add package UA.Azure.Storage --version 4.9.3
NuGet\Install-Package UA.Azure.Storage -Version 4.9.3
<PackageReference Include="UA.Azure.Storage" Version="4.9.3" />
<PackageVersion Include="UA.Azure.Storage" Version="4.9.3" />
<PackageReference Include="UA.Azure.Storage" />
paket add UA.Azure.Storage --version 4.9.3
#r "nuget: UA.Azure.Storage, 4.9.3"
#:package UA.Azure.Storage@4.9.3
#addin nuget:?package=UA.Azure.Storage&version=4.9.3
#tool nuget:?package=UA.Azure.Storage&version=4.9.3
UA.Azure.Storage
UA.Azure.Storage provides a lightweight, efficient implementation for accessing Azure Storage Services (Blob, Queue, and Table) in .NET applications. Built on the Tenet Framework principles, it offers a simplified agent-based approach to interact with Azure Storage without the overhead of heavy SDK dependencies.
Features
💾 Blob Storage Agent
- Container Management: Create, delete, list, and configure blob containers
- Blob Operations: Upload, download, copy, delete, and list blobs
- Metadata Management: Set and retrieve custom metadata
- Blob Properties: Manage blob properties and tags
- Query Contents: Execute SQL-like queries on blob data
- Lease Management: Implement distributed locking with blob leases
- Versioning & Snapshots: Support for blob versioning and snapshots
📬 Queue Storage Agent
- Queue Management: Create, delete, and configure queues
- Message Operations: Send, receive, peek, and delete messages
- Batch Operations: Process multiple messages efficiently
- Message Visibility: Control message visibility timeout
- Queue Metadata: Manage queue-level metadata and properties
📊 Table Storage Agent
- Table Management: Create, delete, and list tables
- Entity Operations: Insert, update, delete, and query entities
- Batch Transactions: Atomic batch operations within a partition
- OData Queries: Advanced filtering and querying capabilities
- Flexible Schema: Work with dynamic entity properties
- Partition & Row Keys: Efficient data organization and retrieval
🔧 Common Features
- Connection String Based: Simple authentication using connection strings
- Request ID Management: Automatic or manual request ID assignment for tracking
- Service Properties: Configure CORS, logging, metrics, and more
- Service Statistics: Retrieve geo-replication statistics
- Shared Access Signatures: Generate and use SAS tokens
- Custom Headers: Full control over request headers
Installation
Install via NuGet Package Manager:
dotnet add package UA.Azure.Storage
Or via Package Manager Console:
Install-Package UA.Azure.Storage
Quick Start
Blob Storage Operations
using UA.Azure.Storage.Blob;
using UA.Azure.Storage.Blob.Models;
// Initialize the blob agent
var blobAgent = new BlobAgent(connectionString, autoAssignRequestId: true);
// Create a container
await blobAgent.CreateContainerAsync(new ContainerRequest
{
Name = "my-container",
PublicAccess = PublicAccessType.Blob
});
// Upload a blob
await blobAgent.UploadBlobAsync(new BlobRequest
{
ContainerName = "my-container",
BlobName = "document.pdf",
Content = fileStream,
ContentType = "application/pdf"
});
// Download a blob
var blob = await blobAgent.GetBlobAsync("my-container", "document.pdf");
// List blobs in a container
var blobs = await blobAgent.ListBlobsAsync("my-container");
foreach (var blobItem in blobs.Items)
{
Console.WriteLine($"Blob: {blobItem.Name}, Size: {blobItem.Properties.ContentLength}");
}
// Delete a blob
await blobAgent.DeleteBlobAsync("my-container", "document.pdf");
Queue Storage Operations
using UA.Azure.Storage.Queue;
using UA.Azure.Storage.Queue.Models;
// Initialize the queue agent
var queueAgent = new QueueAgent(connectionString, autoAssignRequestId: true);
// Create a queue
await queueAgent.CreateQueueAsync(new QueueRequest { Name = "processing-queue" });
// Send a message
await queueAgent.SendMessageAsync(new MessageRequest
{
QueueName = "processing-queue",
MessageText = "Process order #12345",
VisibilityTimeout = TimeSpan.FromMinutes(5),
TimeToLive = TimeSpan.FromDays(7)
});
// Receive messages
var messages = await queueAgent.ReceiveMessagesAsync("processing-queue", maxMessages: 10);
foreach (var message in messages.Items)
{
Console.WriteLine($"Message: {message.MessageText}");
// Process the message...
// Delete the message after processing
await queueAgent.DeleteMessageAsync("processing-queue", message.MessageId, message.PopReceipt);
}
// Peek messages without dequeuing
var peekedMessages = await queueAgent.PeekMessagesAsync("processing-queue", maxMessages: 5);
Table Storage Operations
using UA.Azure.Storage.Table;
using UA.Azure.Storage.Table.Models;
// Initialize the table agent
var tableAgent = new TableAgent(connectionString, autoAssignRequestId: true);
// Create a table
await tableAgent.CreateTableAsync("Customers");
// Insert an entity
var customer = new Dictionary<string, object>
{
["PartitionKey"] = "USA",
["RowKey"] = "customer001",
["Name"] = "John Doe",
["Email"] = "john@example.com",
["Age"] = 35
};
await tableAgent.InsertEntityAsync(new EntityRequest
{
TableName = "Customers",
Entity = customer
});
// Query entities
var query = new ODataQuery
{
Filter = "Age gt 30",
Select = new[] { "Name", "Email", "Age" },
Top = 100
};
var entities = await tableAgent.QueryEntitiesAsync("Customers", query);
// Update an entity
customer["Email"] = "john.doe@example.com";
await tableAgent.UpdateEntityAsync(new EntityRequest
{
TableName = "Customers",
Entity = customer,
ETag = "*" // Use specific ETag for optimistic concurrency
});
// Batch operations
var batchRequest = new BatchRequest
{
TableName = "Customers",
PartitionKey = "USA"
};
batchRequest.AddInsert(entity1);
batchRequest.AddUpdate(entity2);
batchRequest.AddDelete(entity3);
await tableAgent.ExecuteBatchAsync(batchRequest);
// Delete an entity
await tableAgent.DeleteEntityAsync("Customers", "USA", "customer001");
Working with Blob Queries
using UA.Azure.Storage.Blob.Models.Query;
// Query blob contents using SQL-like syntax
var queryRequest = new QueryRequest
{
QueryExpression = "SELECT * FROM BlobStorage WHERE Age > 25",
InputSerialization = new InputSerialization
{
Format = new JsonTextConfiguration
{
RecordSeparator = "\n"
}
},
OutputSerialization = new OutputSerialization
{
Format = new JsonTextConfiguration
{
RecordSeparator = "\n"
}
}
};
var result = await blobAgent.QueryBlobContentsAsync("my-container", "data.json", queryRequest);
Architecture
UA.Azure.Storage is built on three main agent classes:
- BlobAgent: Manages blob containers and blobs
- QueueAgent: Handles queue operations and messages
- TableAgent: Provides NoSQL table storage capabilities
All agents inherit from StorageAgentBase, providing common functionality like:
- Request ID management
- Service properties configuration
- Response handling
- Error management
Configuration
Using Connection Strings
// From appsettings.json
var connectionString = configuration.GetConnectionString("AzureStorage");
// Direct connection string
var connectionString = "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey;EndpointSuffix=core.windows.net";
var blobAgent = new BlobAgent(connectionString);
Dependency Injection
builder.Services.AddSingleton<BlobAgent>(sp =>
new BlobAgent(configuration.GetConnectionString("AzureStorage"), autoAssignRequestId: true));
builder.Services.AddSingleton<QueueAgent>(sp =>
new QueueAgent(configuration.GetConnectionString("AzureStorage"), autoAssignRequestId: true));
builder.Services.AddSingleton<TableAgent>(sp =>
new TableAgent(configuration.GetConnectionString("AzureStorage"), autoAssignRequestId: true));
Performance
UA.Azure.Storage is designed for performance:
- Minimal dependencies (only UA.Tenet core)
- Direct REST API calls without SDK overhead
- Efficient serialization using System.Text.Json
- Support for streaming large files
- Batch operations for bulk processing
Documentation
For comprehensive documentation, tutorials, and API reference, visit:
Made with ❤️ by UA Devs @ Chiclana de la Frontera (Spain)
| 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. 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 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. |
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://tenet.uadevs.org/ for release notes and documentation.