AzureFunctions.TestFramework.Redis
0.13.2
dotnet add package AzureFunctions.TestFramework.Redis --version 0.13.2
NuGet\Install-Package AzureFunctions.TestFramework.Redis -Version 0.13.2
<PackageReference Include="AzureFunctions.TestFramework.Redis" Version="0.13.2" />
<PackageVersion Include="AzureFunctions.TestFramework.Redis" Version="0.13.2" />
<PackageReference Include="AzureFunctions.TestFramework.Redis" />
paket add AzureFunctions.TestFramework.Redis --version 0.13.2
#r "nuget: AzureFunctions.TestFramework.Redis, 0.13.2"
#:package AzureFunctions.TestFramework.Redis@0.13.2
#addin nuget:?package=AzureFunctions.TestFramework.Redis&version=0.13.2
#tool nuget:?package=AzureFunctions.TestFramework.Redis&version=0.13.2
AzureFunctions.TestFramework.Redis
Redis Trigger, Input, and Output binding support for the Azure Functions Test Framework.
Installation
dotnet add package AzureFunctions.TestFramework.Redis
Supported bindings
| Binding | Attribute | Description |
|---|---|---|
[RedisPubSubTrigger] |
Trigger | Receives a message from a Redis pub/sub channel |
[RedisListTrigger] |
Trigger | Receives a value popped from a Redis list |
[RedisStreamTrigger] |
Trigger | Receives entries from a Redis stream |
[RedisInput] |
Input | Executes a Redis command and injects the result |
[RedisOutput] |
Output | Executes a Redis command with the function's return value — captured via FunctionInvocationResult |
Redis Pub/Sub Trigger
Use InvokeRedisPubSubAsync to simulate a Redis pub/sub channel message trigger.
var result = await host.InvokeRedisPubSubAsync(
"ProcessPubSubMessage",
channel: "notifications",
message: "hello from redis");
Assert.True(result.Success);
Function example
[Function("ProcessPubSubMessage")]
public void Run(
[RedisPubSubTrigger("%RedisConnection%", "notifications")] string message)
{
_logger.LogInformation("Received pub/sub message: {Message}", message);
}
Redis List Trigger
Use InvokeRedisListAsync to simulate a value being popped from a Redis list.
var result = await host.InvokeRedisListAsync(
"ProcessListEntry",
key: "work-queue",
value: "task-payload");
Assert.True(result.Success);
Function example
[Function("ProcessListEntry")]
public void Run(
[RedisListTrigger("%RedisConnection%", "work-queue")] string entry)
{
_logger.LogInformation("Processing list entry: {Entry}", entry);
}
Redis Stream Trigger
Use InvokeRedisStreamAsync to simulate a Redis stream entry trigger. The entries are passed as
a list of name-value pairs and serialized to a JSON array of {"name":"…","value":"…"} objects.
var entries = new[]
{
new KeyValuePair<string, string>("field1", "value1"),
new KeyValuePair<string, string>("field2", "value2")
};
var result = await host.InvokeRedisStreamAsync(
"ProcessStreamEntry",
key: "mystream",
entries: entries);
Assert.True(result.Success);
Function example
[Function("ProcessStreamEntry")]
public void Run(
[RedisStreamTrigger("%RedisConnection%", "mystream")] string entriesJson)
{
_logger.LogInformation("Received stream entries: {Entries}", entriesJson);
}
Redis Input Binding
Register a fake Redis command result via the builder so it is injected automatically for every
invocation of functions that declare a [RedisInput] parameter.
var host = await new FunctionsTestHostBuilder()
.WithFunctionsAssembly(typeof(MyFunction).Assembly)
.WithHostBuilderFactory(Program.CreateHostBuilder)
// Inject the result of "GET mykey" as "cached-value"
.WithRedisInput("GET mykey", "cached-value")
.BuildAndStartAsync();
Use WithRedisInputJson(command, json) to inject a pre-serialized JSON value.
The command must exactly match the value declared in the [RedisInput] attribute's command
argument (case-insensitive).
Function example
[Function("ReadRedisInput")]
public void Run(
[QueueTrigger("redis-input-queue")] string unused,
[RedisInput("%RedisConnection%", "GET mykey")] string cachedValue)
{
_logger.LogInformation("Cached value: {Value}", cachedValue);
}
Redis Output Binding
Output bindings are captured automatically via FunctionInvocationResult:
var result = await host.InvokeRedisPubSubAsync("WriteRedisOutput", "chan", "my-message");
Assert.True(result.Success);
var written = result.ReadReturnValueAs<string>();
Assert.Equal("my-message", written);
Function example
[Function("WriteRedisOutput")]
[RedisOutput("%RedisConnection%", "SET outkey")]
public string? Run(
[RedisPubSubTrigger("%RedisConnection%", "chan")] string message)
{
return message;
}
Testing across all four flavours
Add the Redis package reference to your test project and all four function-app test flavours:
<PackageReference Include="AzureFunctions.TestFramework.Redis" />
See the 4-flavour matrix test pattern for the concrete test class structure.
| 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 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. |
-
net10.0
- AzureFunctions.TestFramework.Core (>= 0.13.2)
- Microsoft.Azure.Functions.Worker.Extensions.Redis (>= 1.0.0)
-
net8.0
- AzureFunctions.TestFramework.Core (>= 0.13.2)
- Microsoft.Azure.Functions.Worker.Extensions.Redis (>= 1.0.0)
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 | 90 | 4/30/2026 |