Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft. All rights reserved.

using Microsoft.Azure.Functions.Worker;
using Microsoft.DurableTask;

namespace HostedAgent;

public static class DurableTriggerDiscovery
{
[Function(nameof(DurableTriggerDiscovery))]
public static Task RunAsync([OrchestrationTrigger] TaskOrchestrationContext context)
{
// The isolated worker SDK indexes Durable triggers from the app assembly.
// Hosting-only apps still need one local orchestrator for discovery.
return Task.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ func start

The Azure Functions app will be available at `http://localhost:7071`.

If the hosted agent routes are not listed when the app starts, make sure the app defines at least one local `[OrchestrationTrigger]` function. In .NET isolated worker apps, the Durable extension is indexed from triggers discovered in the app assembly.

### Test the Azure Functions app

The README.md file in each sample directory contains instructions for testing the sample. Each sample also includes a `demo.http` file that can be used to test the sample from the command line. These files can be opened in VS Code with the [REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) extension or in the Visual Studio IDE.
Expand Down
12 changes: 12 additions & 0 deletions dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ app.Run();

By default, each agent can be invoked via a built-in HTTP trigger function at the route `http[s]://[host]/api/agents/{agentName}/run`.

> [!NOTE]
> In .NET isolated Azure Functions apps, the worker SDK discovers Durable Functions triggers from the app assembly. If your app only hosts agents through `ConfigureDurableAgents(...)` and does not define any Durable orchestrator functions, add a small `[OrchestrationTrigger]` function in your app assembly so the Durable extension is indexed.
Comment on lines 62 to +65

```csharp
public static class DurableTriggerDiscovery
{
[Function(nameof(DurableTriggerDiscovery))]
public static Task RunAsync([OrchestrationTrigger] TaskOrchestrationContext context)
=> Task.CompletedTask;
}
```

### Orchestrating hosted agents

This package also provides a set of extension methods such as `GetAgent` on the [`TaskOrchestrationContext`](https://learn.microsoft.com/dotnet/api/microsoft.durabletask.taskorchestrationcontext) class for interacting with hosted agents within orchestrations.
Expand Down