Skip to content

Commit 71c22e7

Browse files
Update articles/azure-functions/dotnet-isolated-process-guide.md
Co-authored-by: Glenn Gailey <[email protected]>
1 parent e7ee4f8 commit 71c22e7

File tree

1 file changed

+1
-30
lines changed

1 file changed

+1
-30
lines changed

articles/azure-functions/dotnet-isolated-process-guide.md

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -142,36 +142,7 @@ A function can accept a [CancellationToken](/dotnet/api/system.threading.cancell
142142

143143
Cancellation tokens are supported in .NET isolated functions. The following example shows how to use a cancellation token in a function:
144144

145-
146-
```csharp
147-
[Function("Function1")]
148-
public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req, FunctionContext executionContext, CancellationToken cancellationToken)
149-
{
150-
_logger.LogInformation("HttpTriggerWithCancellation function triggered");
151-
_logger.LogInformation("C# HTTP trigger function processed a request.");
152-
153-
try
154-
{
155-
var response = req.CreateResponse(HttpStatusCode.OK);
156-
response.Headers.Add("Content-Type", "text/plain; charset=utf-8");
157-
158-
response.WriteString("Welcome to Azure Functions!");
159-
160-
await Task.Delay(5000, cancellationToken);
161-
162-
return response;
163-
}
164-
catch (OperationCanceledException) {
165-
166-
_logger.LogInformation("Function invocation cancelled");
167-
var response = req.CreateResponse(HttpStatusCode.ServiceUnavailable);
168-
response.WriteString("Invocation cancelled");
169-
170-
return response;
171-
}
172-
173-
}
174-
```
145+
:::code language="csharp" source="~/azure-functions-dotnet-worker/samples/Net7Worker/HttpFunction.cs" range="23-51":::
175146

176147
## ReadyToRun
177148

0 commit comments

Comments
 (0)