AzureFunctions.TestFramework.Dapr 0.13.2

dotnet add package AzureFunctions.TestFramework.Dapr --version 0.13.2
                    
NuGet\Install-Package AzureFunctions.TestFramework.Dapr -Version 0.13.2
                    
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="AzureFunctions.TestFramework.Dapr" Version="0.13.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AzureFunctions.TestFramework.Dapr" Version="0.13.2" />
                    
Directory.Packages.props
<PackageReference Include="AzureFunctions.TestFramework.Dapr" />
                    
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 AzureFunctions.TestFramework.Dapr --version 0.13.2
                    
#r "nuget: AzureFunctions.TestFramework.Dapr, 0.13.2"
                    
#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 AzureFunctions.TestFramework.Dapr@0.13.2
                    
#: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=AzureFunctions.TestFramework.Dapr&version=0.13.2
                    
Install as a Cake Addin
#tool nuget:?package=AzureFunctions.TestFramework.Dapr&version=0.13.2
                    
Install as a Cake Tool

AzureFunctions.TestFramework.Dapr

Dapr Trigger, Input, and Output binding support for the Azure Functions Test Framework.

Installation

dotnet add package AzureFunctions.TestFramework.Dapr

Supported bindings

Binding Attribute Description
[DaprBindingTrigger] Trigger Fires on a Dapr input binding event
[DaprServiceInvocationTrigger] Trigger Fires on a Dapr service invocation call
[DaprTopicTrigger] Trigger Fires on a Dapr pub/sub topic message
[DaprStateInput] Input Reads state from a Dapr state store (see limitations)
[DaprSecretInput] Input Reads a secret from a Dapr secret store (see limitations)
[DaprStateOutput] Output Saves state to a Dapr state store — OutputData is currently empty with Dapr extension v1.0.1 (see known limitation)
[DaprInvokeOutput] Output Invokes another Dapr app — OutputData is currently empty with Dapr extension v1.0.1 (see known limitation)
[DaprPublishOutput] Output Publishes a message to a Dapr topic — OutputData is currently empty with Dapr extension v1.0.1 (see known limitation)
[DaprBindingOutput] Output Sends a value to a Dapr output binding — OutputData is currently empty with Dapr extension v1.0.1 (see known limitation)

Note: The Dapr extension is supported in Kubernetes, Azure Container Apps, Azure IoT Edge, and other self-hosted modes only. It is not available in the Azure Functions Consumption plan.

DaprBindingTrigger

Use InvokeDaprBindingAsync to simulate a Dapr input binding event trigger.

var result = await host.InvokeDaprBindingAsync(
    "ProcessDaprBinding",
    data: "my-event-data");

Assert.True(result.Success);

Pass a POCO to have it serialized to JSON automatically:

var payload = new MyEvent { Id = "evt-1", Message = "hello" };

var result = await host.InvokeDaprBindingAsync(
    "ProcessDaprBinding",
    data: payload);

Assert.True(result.Success);

Function example

[Function("ProcessDaprBinding")]
public void Run(
    [DaprBindingTrigger(BindingName = "my-binding")] string data)
{
    _logger.LogInformation("Received Dapr binding event: {Data}", data);
}

DaprServiceInvocationTrigger

Use InvokeDaprServiceInvocationAsync to simulate a Dapr service invocation call.

var result = await host.InvokeDaprServiceInvocationAsync(
    "HandleInvocation",
    body: "request-body");

Assert.True(result.Success);

Pass a POCO to have it serialized to JSON automatically:

var request = new MyRequest { OrderId = "ord-42" };

var result = await host.InvokeDaprServiceInvocationAsync(
    "HandleInvocation",
    body: request);

Assert.True(result.Success);

Function example

[Function("HandleInvocation")]
public void Run(
    [DaprServiceInvocationTrigger] string body)
{
    _logger.LogInformation("Dapr service invocation: {Body}", body);
}

DaprTopicTrigger

Use InvokeDaprTopicAsync to simulate a Dapr pub/sub topic message trigger.

var result = await host.InvokeDaprTopicAsync(
    "ProcessTopicMessage",
    message: "hello from dapr pub/sub");

Assert.True(result.Success);

Pass a POCO to have it serialized to JSON automatically:

var order = new Order { Id = "ord-1", Amount = 99.99m };

var result = await host.InvokeDaprTopicAsync(
    "ProcessTopicMessage",
    message: order);

Assert.True(result.Success);

Function example

[Function("ProcessTopicMessage")]
public void Run(
    [DaprTopicTrigger("my-pubsub", Topic = "orders")] string message)
{
    _logger.LogInformation("Received Dapr topic message: {Message}", message);
}

Output bindings

Output bindings are captured automatically via FunctionInvocationResult when the worker SDK correctly marks them as output bindings.

Note: Due to a known bug in the Dapr extension's source generator (v1.0.1), properties decorated with Dapr output binding attributes (e.g. [DaprPublishOutput], [DaprStateOutput], etc.) on POCO return types are generated with direction: "In" instead of direction: "Out". As a result, the worker SDK does not populate InvocationResponse.OutputData for these properties and FunctionInvocationResult.OutputData will be empty. Functions with Dapr output bindings still execute successfully.

Dapr input binding limitations

Note: The Azure Functions Worker SDK source generator (as of v2.0.7) does not emit binding metadata for [DaprStateInput] or [DaprSecretInput] parameters. Because of this, the WithDaprStateInput and WithDaprSecretInput builder extensions have no effect in source-generated mode.

To work with [DaprStateInput] or [DaprSecretInput] in integration tests, override the Dapr HTTP client in DI to return a fake response from the Dapr sidecar endpoint:

var host = await new FunctionsTestHostBuilder()
    .WithFunctionsAssembly(typeof(MyFunction).Assembly)
    .WithHostBuilderFactory(Program.CreateHostBuilder)
    .ConfigureServices(services =>
    {
        // Replace the Dapr HTTP client to return a fake state value
        services.AddHttpClient("dapr-client", client => { ... });
    })
    .BuildAndStartAsync();

When the source generator is updated to emit daprState and daprSecret binding metadata, the WithDaprStateInput and WithDaprSecretInput extensions will work automatically without any additional configuration.

Testing across all four flavours

Add the Dapr package reference to your test project and all four function-app test flavours:

<PackageReference Include="AzureFunctions.TestFramework.Dapr" />

See the 4-flavour matrix test pattern for the concrete test class structure.

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 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. 
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
0.13.2 92 4/30/2026