AzureDotnetDev.Funcky
1.0.4
dotnet add package AzureDotnetDev.Funcky --version 1.0.4
NuGet\Install-Package AzureDotnetDev.Funcky -Version 1.0.4
<PackageReference Include="AzureDotnetDev.Funcky" Version="1.0.4" />
<PackageVersion Include="AzureDotnetDev.Funcky" Version="1.0.4" />
<PackageReference Include="AzureDotnetDev.Funcky" />
paket add AzureDotnetDev.Funcky --version 1.0.4
#r "nuget: AzureDotnetDev.Funcky, 1.0.4"
#:package AzureDotnetDev.Funcky@1.0.4
#addin nuget:?package=AzureDotnetDev.Funcky&version=1.0.4
#tool nuget:?package=AzureDotnetDev.Funcky&version=1.0.4
AzureDotnetDev.Funcky
Helpers and extensions to reduce boilerplate when building Azure Functions on .NET 8.0 and .NET 9.0. Focused on clean DI, simple configuration, and safe defaults.
Features
- Service Bus topic-to-queue forwarder as a single call
- Attribute-based binding for topic-to-queue forwarders
- Assembly scanning to automatically bind all topic-to-queue forwarders in a given assembly
- Async-first API with a convenient sync wrapper
- Flexible configuration via connection strings or an explicit
TokenCredential
Install
dotnet add package AzureDotnetDev.Funcky
NuGet package includes XML docs, README, and symbols.
Quick start
Minimal example with .NET isolated Functions:
using Microsoft.Extensions.Hosting;
using AzureDotnetDev.Funcky.Extensions.ServiceBus;
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.Build();
// Ensures a subscription on "orders" forwards to queue "billing"
await host.UseTopicBoundQueueAsync("orders", "billing");
await host.RunAsync();
Attribute-based binding
Use TopicBoundQueueAttribute to declare a topic-to-queue forwarder directly on a function method and bind all such attributes at startup.
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Hosting;
using AzureDotnetDev.Funcky.Extensions.ServiceBus;
public class MyFunctions
{
[Function("ProcessOrder")]
[TopicBoundQueue("%OrdersTopic%", "%BillingQueue%", SubscriptionName = "%BillingSubscription%", Connection = "ServiceBusConnection", AutoCreateEntities = true, AutoDeleteOnIdle = "7d")]
public Task Run([ServiceBusTrigger("%BillingQueue%", Connection = "ServiceBusConnection")] string body)
=> Task.CompletedTask;
}
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.Build();
host.UseTopicBoundQueuesFromAssemblyContaining<MyFunctions>();
await host.RunAsync();
- Placeholders like
%Key%resolve viaIConfigurationfrom connection strings or standard configuration keys. SubscriptionNamedefaults toQueueNameif omitted.Connectionaccepts either a connection string key or a fully qualified namespace key.- Namespace-based configuration requires the explicit
TokenCredentialscanner overload. - When
AutoCreateEntitiesis true, missing topic/queue/subscription are created; optionalAutoDeleteOnIdlesupportsTimeSpanformats such as7.00:00:00,Xdsuch as7d, or ISO-8601 day values such asP7D.
Configuration modes
You can configure the Service Bus administration client in three ways.
- Connection string
App settings key defaults to ServiceBusConnection. Override by passing your own key name.
await host.UseTopicBoundQueueAsync("mytopic", "myqueue", "ServiceBusConnection");
App settings example:
{
"ConnectionStrings": {
"ServiceBusConnection": "Endpoint=sb://your-ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=..."
}
}
- Attribute scanning with fully qualified namespace and explicit credential
If the key name ends with __fullyQualifiedNamespace or :fullyQualifiedNamespace, the value is treated as an FQDN such as your-ns.servicebus.windows.net. If a regular key is missing, an alternate key with either suffix is also checked.
using Azure.Identity;
using AzureDotnetDev.Funcky.Extensions.ServiceBus;
var credential = new DefaultAzureCredential();
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.Build()
.UseTopicBoundQueuesFromAssemblyContaining<MyFunctions>(credential);
await host.RunAsync();
App settings example:
{
"ConnectionStrings": {
"ServiceBusConnection__fullyQualifiedNamespace": "your-ns.servicebus.windows.net"
}
}
- Direct custom credential
Bring your own TokenCredential and FQDN explicitly when not using attributes:
using Azure.Identity;
using AzureDotnetDev.Funcky.Extensions.ServiceBus;
var credential = new DefaultAzureCredential();
await host.UseTopicBoundQueueAsync(
topicName: "topic",
queueName: "queue",
credential: credential,
fullyQualifiedNamespace: "your-ns.servicebus.windows.net");
API surface
// Async-first
Task<IHost> UseTopicBoundQueueAsync(this IHost host, string topicName, string queueName, string connectionStringName = "ServiceBusConnection");
Task<IHost> UseTopicBoundQueueAsync(this IHost host, string topicName, string queueName, TokenCredential credential, string fullyQualifiedNamespace);
// Convenience sync wrappers
IHost UseTopicBoundQueue(this IHost host, string topicName, string queueName, string connectionStringName = "ServiceBusConnection");
IHost UseTopicBoundQueue(this IHost host, string topicName, string queueName, TokenCredential credential, string fullyQualifiedNamespace);
// Attribute + assembly scanning
IHost UseTopicBoundQueuesFromAssemblyContaining<TMarker>(this IHost host);
IHost UseTopicBoundQueuesFromAssemblyContaining<TMarker>(this IHost host, TokenCredential credential);
IHost UseTopicBoundQueuesFromAssemblies(this IHost host, params Assembly[] assemblies);
IHost UseTopicBoundQueuesFromAssemblies(this IHost host, TokenCredential credential, params Assembly[] assemblies);
// Attribute
sealed class TopicBoundQueueAttribute(string topicName, string queueName)
{
string TopicName { get; } // supports "%Key%" placeholders
string QueueName { get; } // supports "%Key%" placeholders
string? SubscriptionName { get; set; } // defaults to QueueName
string? Connection { get; set; } // connection string key or FQDN key
bool AutoCreateEntities { get; set; } // default: false
string? AutoDeleteOnIdle { get; set; } // e.g., "7d", "7.00:00:00", "P7D"
}
Notes and requirements
- When using credentials instead of a connection string, the principal must have permissions to manage Service Bus entities, such as Azure Service Bus Data Owner.
- If namespace-based configuration is used without a credential overload, the library throws a clear
InvalidOperationException. - The topic and queue must already exist unless
AutoCreateEntitiesis true. - Topic subscriptions require Azure Service Bus Standard or higher.
- Forwarding requires both entities in the same namespace.
Target frameworks
- .NET 8.0
- .NET 9.0
Versioning
- Semantic Versioning (SemVer): MAJOR.MINOR.PATCH
License
- MIT
Contributing
Issues and PRs welcome. Please keep changes small, focused, and well-tested.
| 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 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. |
-
net8.0
- Azure.Core (>= 1.60.0)
- Azure.Messaging.ServiceBus (>= 7.20.2)
- Microsoft.Extensions.DependencyInjection (>= 10.0.10)
- Microsoft.Extensions.Hosting (>= 10.0.10)
- Microsoft.Extensions.Logging (>= 10.0.10)
-
net9.0
- Azure.Core (>= 1.60.0)
- Azure.Messaging.ServiceBus (>= 7.20.2)
- Microsoft.Extensions.DependencyInjection (>= 9.0.8)
- Microsoft.Extensions.Hosting (>= 9.0.8)
- Microsoft.Extensions.Logging (>= 9.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release of Azure Functions helpers for DI and Service Bus.