Skip to content

Commit 2ab9e6c

Browse files
Merge pull request #301647 from nytian/http-feature
Add .NET Isolated Support Note and Samples for HTTP 202 Automatic Polling
2 parents 2eeb134 + 9a96249 commit 2ab9e6c

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

articles/azure-functions/durable/durable-functions-http-features.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,67 @@ By using the "call HTTP" action, you can do the following actions in your orches
350350

351351
The ability to consume HTTP APIs directly from orchestrator functions is intended as a convenience for a certain set of common scenarios. You can implement all of these features yourself using activity functions. In many cases, activity functions might give you more flexibility.
352352

353-
### <a name="http-202-handling"></a>HTTP 202 handling (.NET in-process only)
353+
### <a name="http-202-handling"></a>HTTP 202 handling (.NET only)
354354

355355
The "call HTTP" API can automatically implement the client side of the polling consumer pattern. If a called API returns an HTTP 202 response with a Location header, the orchestrator function automatically polls the Location resource until receiving a response other than 202. This response will be the response returned to the orchestrator function code.
356356

357+
# [C# (InProc)](#tab/csharp-inproc)
358+
359+
```csharp
360+
[FunctionName(nameof(CheckSiteAvailabilityWithPolling))]
361+
public static async Task CheckSiteAvailabilityWithPolling(
362+
[OrchestrationTrigger] IDurableOrchestrationContext context)
363+
{
364+
Uri url = context.GetInput<Uri>();
365+
366+
// HTTP automatic polling on 202 response is enabled by default in .NET in-process.
367+
DurableHttpResponse response =
368+
await context.CallHttpAsync(HttpMethod.Get, url);
369+
}
370+
```
371+
372+
# [C# (Isolated)](#tab/csharp-isolated)
373+
374+
```csharp
375+
[Function(nameof(CheckSiteAvailabilityWithPolling))]
376+
public static async Task CheckSiteAvailabilityWithPolling(
377+
[OrchestrationTrigger] TaskOrchestrationContext context)
378+
{
379+
Uri url = context.GetInput<Uri>();
380+
381+
// Enable HTTP automatic polling on 202 response by setting asynchronousPatternEnabled to true.
382+
DurableHttpResponse response =await context.CallHttpAsync(
383+
HttpMethod.Get,
384+
url!,
385+
content: null,
386+
retryOptions: null,
387+
asynchronousPatternEnabled: true)
388+
}
389+
390+
```
391+
# [JavaScript](#tab/javascript)
392+
393+
This feature is currently not supported in JavaScript.
394+
395+
# [Python](#tab/python)
396+
397+
This feature is currently not supported in Python.
398+
399+
# [PowerShell](#tab/powershell)
400+
401+
This feature is currently not supported in PowerShell.
402+
403+
# [Java](#tab/java)
404+
405+
This feature is currently not supported in Java.
406+
407+
---
408+
357409
> [!NOTE]
358410
> 1. Orchestrator functions also natively support the server-side polling consumer pattern, as described in [Async operation tracking](#async-operation-tracking). This support means that orchestrations in one function app can easily coordinate the orchestrator functions in other function apps. This is similar to the [sub-orchestration](durable-functions-sub-orchestrations.md) concept, but with support for cross-app communication. This support is particularly useful for microservice-style app development.
359-
> 2. The built-in HTTP polling pattern is currently available only in the .NET in-process host.
411+
> 2. The built-in HTTP polling pattern is currently available only in the .NET host.
412+
> 3. The polling pattern is enabled by default in .NET in-process but disabled by default in .NET Isolated. If you want to enable it in .NET Isolated, refer to the sample code and set the asynchronousPatternEnabled argument to true.
413+
> 4. HTTP automatic polling pattern is supported in Durable Functions .NET Isolated starting from version [v1.5.0](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.DurableTask) or later.
360414
361415
### Managed identities
362416

0 commit comments

Comments
 (0)