AzureBlast 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AzureBlast --version 1.0.0
                    
NuGet\Install-Package AzureBlast -Version 1.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="AzureBlast" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AzureBlast" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AzureBlast" />
                    
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 AzureBlast --version 1.0.0
                    
#r "nuget: AzureBlast, 1.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.
#:package AzureBlast@1.0.0
                    
#: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=AzureBlast&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AzureBlast&version=1.0.0
                    
Install as a Cake Tool

AzureBlast

RoadWarrior

AzureBlast is a lightweight, injectable .NET library that simplifies working with Azure services—including SQL Server, Service Bus, Key Vault, Table Storage, and ARM (Resource Manager)—from applications, scripts, and tools. It’s designed to be DI-friendly and easy to unit test.

✨ Features

  • MSSQL – simple API for parameterized queries and metadata loading.
  • Azure Service Bus – send single/batch/scheduled messages; receive & complete.
  • Azure Key Vault – initialize a vault and get/set/delete/purge secrets.
  • Azure Table Storage – list tables, set a table, upsert/query/delete entities.
  • Azure Resource Manager (ARM) – list subscriptions, set subscription context, query resources.
  • Two DI styles – options-based AddAzureBlast(...) or a fluent builder via UseAzureBlast(...).
  • Script-friendlyAzureBlastFactory for LINQPad/PowerShell/console scenarios.
  • Testable – interfaces and adapters to mock sealed SDK types.

📦 Installation

dotnet add package AzureBlast

Targets .NET 8+. Authentication defaults to DefaultAzureCredential unless you supply a TokenCredential.

🔐 Authentication

By default, AzureBlast uses DefaultAzureCredential. You can pass a custom TokenCredential if you need a specific auth flow (client secret, managed identity from a particular resource, etc.).

using Azure.Identity;
var cred = new ClientSecretCredential(tenantId, clientId, clientSecret);

🧰 Choose your setup

1) Options-based DI registration (one-shot)

using AzureBlast;
using Microsoft.Extensions.DependencyInjection;
using Azure.Identity; // only if you override Credential

var services = new ServiceCollection();

services.AddAzureBlast(o =>
{
    o.SqlConnectionString          = "Server=.;Database=App;Trusted_Connection=True;";
    o.KeyVaultUrl                  = "https://contoso.vault.azure.net/";
    o.TableStorageConnectionString = "UseDevelopmentStorage=true;";
    o.TableName                    = "MyTable";
    o.ServiceBusConnectionString   = "<sb-connection-string>";
    o.ServiceBusQueueName          = "orders";

    // Optional credential override (otherwise DefaultAzureCredential is used):
    // o.Credential = new DefaultAzureCredential();
});

var sp = services.BuildServiceProvider();

This path uses TryAdd* so your own prior registrations aren’t overwritten.

2) Fluent builder (incremental)

using AzureBlast;
using Microsoft.Extensions.DependencyInjection;
using Azure.Identity;

var services = new ServiceCollection();

// DefaultAzureCredential:
services
    .UseAzureBlast()
    .WithSql("Server=.;Database=App;Trusted_Connection=True;")
    .WithKeyVault("https://contoso.vault.azure.net/")
    .WithTableStorage("UseDevelopmentStorage=true;", "MyTable")
    .WithServiceBus("<sb-connection-string>", "orders")
    .Build();

// Or supply a custom TokenCredential:
services
    .UseAzureBlast(new DefaultAzureCredential())
    .WithKeyVault("https://contoso.vault.azure.net/")
    .Build();

var sp = services.BuildServiceProvider();

3) Adhoc (no DI) via AzureBlastFactory — scripts, LINQPad, PowerShell

using AzureBlast;

// Build a provider ad-hoc with options (no IServiceCollection needed)
var sp = AzureBlastFactory.CreateServiceProvider(o =>
{
    o.TableStorageConnectionString = "UseDevelopmentStorage=true;";
    o.TableName = "MyTable";
});

// Or construct exactly what you need, directly:
var db = AzureBlastFactory.CreateDatabase("Server=.;Database=App;Trusted_Connection=True;");
var kv = AzureBlastFactory.CreateKeyVault("https://contoso.vault.azure.net/");        // or CreateKeyVaultAsync(...)
var sb = AzureBlastFactory.CreateServiceBus("<sb-conn>", "orders");
var ts = AzureBlastFactory.CreateTableStorage("UseDevelopmentStorage=true;", "MyTable");
var arm = AzureBlastFactory.CreateArmClientWrapper();
var rc  = AzureBlastFactory.CreateResourceClient();

🧪 Using the services

All interfaces live under AzureBlast.Interfaces.

SQL (IMssqlDatabase)

using AzureBlast.Interfaces;

var db = sp.GetRequiredService<IMssqlDatabase>();

var rowsAffected = db.ExecuteNonQuery(
    "UPDATE Users SET IsActive = @active WHERE Id = @id",
    new() { ["@active"] = true, ["@id"] = 42 });

var result = db.ExecuteScalar(
    "SELECT COUNT(*) FROM Users WHERE IsActive = @active",
    new() { ["@active"] = true });

Service Bus (IAzureServiceBus)

using AzureBlast.Interfaces;

// Resolve from DI (already configured via options/fluent)
var bus = sp.GetRequiredService<IAzureServiceBus>();

// Send a message
await bus.SendMessageAsync("""{ "type": "hello", "payload": "AzureBlast" }"" );

// Receive some messages
var received = await bus.ReceiveMessagesAsync(maxMessages: 10);
foreach (var msg in received ?? [])
{
    // ...process...
    await bus.CompleteMessageAsync(msg);
}

Key Vault (IAzureKeyVault)

using AzureBlast.Interfaces;

var kv = sp.GetRequiredService<IAzureKeyVault>();

await kv.SetSecretAsync("MySecret", "shh");
var value = await kv.GetSecretAsync("MySecret");
// value == "shh"

Table Storage (IAzureTableStorage)

using AzureBlast.Interfaces;
using Azure.Data.Tables;

var tables = sp.GetRequiredService<IAzureTableStorage>();

// Optional: switch table at runtime
tables.SetTable("MyTable");

// Define an entity
public class UserEntity : ITableEntity
{
    public string PartitionKey { get; set; } = "Users";
    public string RowKey { get; set; } = Guid.NewGuid().ToString("N");
    public string Name { get; set; } = default!;
    public bool IsActive { get; set; }
    public DateTimeOffset? Timestamp { get; set; }
    public ETag ETag { get; set; }
}

// Upsert
await tables.UpsertEntityAsync(new UserEntity { Name = "Ada", IsActive = true });

// Query
var users = await tables.QueryEntitiesAsync<UserEntity>("IsActive eq true");

// Get & Delete
var first = users.FirstOrDefault();
if (first is not null)
{
    var fetched = await tables.GetEntityAsync<UserEntity>(first.PartitionKey, first.RowKey);
    await tables.DeleteEntityAsync(first.PartitionKey, first.RowKey);
}

ARM / Resource Graph (IAzureResourceClient)

using AzureBlast.Interfaces;

// Always available; wrapper is registered by default.
var rc = sp.GetRequiredService<IAzureResourceClient>();

// List subscriptions and set the one you want
var subs = await rc.ListSubscriptionsAsync();
var subId = subs.First().Id.SubscriptionId!;
await rc.SetSubscriptionContextAsync(subId);

// Explore resources
var groups = await rc.GetResourceGroupsByTagAsync("env", "prod");
var vms    = await rc.GetResourcesByTypeAsync("Microsoft.Compute/virtualMachines");
var exists = await rc.ResourceExistsAsync("rg-app", "my-app-plan");

🧪 Testing

  • The DI registration via options uses TryAdd* so repeated calls don’t duplicate registrations and won’t overwrite your own.
  • Service Bus, Table Storage, and ARM are exposed through interfaces and adapters so you can stub or mock them in unit tests.
  • Example: provide a fake IAzureTableStorage in the test container and assert it’s preserved when calling AddAzureBlast.

📖 API docs

XML documentation is included with the package and covers all public types:

  • ServiceCollectionExtensions.AddAzureBlast(...) (options-based)
  • AzureBlastRegistration.UseAzureBlast(...) (fluent builder)
  • AzureBlastFactory (script/no-DI helpers)
  • IMssqlDatabase, IAzureServiceBus, IAzureKeyVault, IAzureTableStorage, IAzureResourceClient, etc.

📝 Notes

  • Credentials: If you don’t pass a TokenCredential, DefaultAzureCredential is used.
  • Key Vault: The client is initialized during registration via InitializeKeyVaultAsync(vaultUrl) so it’s ready to use.
  • Table Storage: You can set a default table during registration and change it later with SetTable(...).

🔧 Minimal quick-start (Service Bus only)

using AzureBlast;
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();

services.AddAzureBlast(o =>
{
    o.ServiceBusConnectionString = "<sb-connection-string>";
    o.ServiceBusQueueName = "queue1";
});

var sp  = services.BuildServiceProvider();
var bus = sp.GetRequiredService<AzureBlast.Interfaces.IAzureServiceBus>();

await bus.SendMessageAsync("""{ "hello": "world" }""");
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 was computed.  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

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
1.0.2 201 8/24/2025
1.0.0 64 8/23/2025