mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using Microsoft.Azure.Functions.Worker;
|
|
using Microsoft.Azure.Functions.Worker.Http;
|
|
using Microsoft.DurableTask;
|
|
using Microsoft.DurableTask.Client;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace SingleAgent;
|
|
|
|
public static class OrchFunction
|
|
{
|
|
[Function(nameof(OrchFunction))]
|
|
public static async Task<List<string>> RunOrchestratorAsync(
|
|
[OrchestrationTrigger] TaskOrchestrationContext context)
|
|
{
|
|
ILogger logger = context.CreateReplaySafeLogger(nameof(OrchFunction));
|
|
logger.LogInformation("Saying hello.");
|
|
var outputs = new List<string>();
|
|
|
|
outputs.Add("Tokyo");
|
|
|
|
return outputs;
|
|
}
|
|
|
|
[Function("OrchFunction_HttpStart")]
|
|
public static async Task<HttpResponseData> HttpStartAsync(
|
|
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
|
|
[DurableClient] DurableTaskClient client,
|
|
FunctionContext executionContext)
|
|
{
|
|
// Function input comes from the request content.
|
|
string instanceId = await client.ScheduleNewOrchestrationInstanceAsync(
|
|
nameof(OrchFunction));
|
|
|
|
// Returns an HTTP 202 response with an instance management payload.
|
|
// See https://learn.microsoft.com/azure/azure-functions/durable/durable-functions-http-api#start-orchestration
|
|
return await client.CreateCheckStatusResponseAsync(req, instanceId);
|
|
}
|
|
}
|