Skip to content

Commit f755002

Browse files
committed
Add DI extensibility note to durable HTTP article
1 parent 0d46a21 commit f755002

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,38 @@ If any of these limitations might affect your use case, consider instead using a
206206
>
207207
> This design choice is intentional. The primary reason is that custom types help ensure users don't make incorrect assumptions about the supported behaviors of the internal HTTP client. Types specific to Durable Functions also make it possible to simplify API design. They also can more easily make available special features like [managed identity integration](#managed-identities) and the [polling consumer pattern](#http-202-handling).
208208
209+
### Extensibility (.NET only)
210+
211+
Customizing the behavior of the orchestration's internal HTTP client is possible using [Azure Functions .NET dependency injection](https://docs.microsoft.com/azure/azure-functions/functions-dotnet-dependency-injection). This ability can be useful for making small behavioral changes. It can also be useful for unit testing the HTTP client by injecting mock objects.
212+
213+
The following example demonstrates using dependency injection to disable SSL certificate validation for orchestrator functions that call external HTTP endpoints.
214+
215+
```csharp
216+
public class Startup : FunctionsStartup
217+
{
218+
public override void Configure(IFunctionsHostBuilder builder)
219+
{
220+
// Register own factory
221+
builder.Services.AddSingleton<
222+
IDurableHttpMessageHandlerFactory,
223+
MyDurableHttpMessageHandlerFactory>();
224+
}
225+
}
226+
227+
public class MyDurableHttpMessageHandlerFactory : IDurableHttpMessageHandlerFactory
228+
{
229+
public HttpMessageHandler CreateHttpMessageHandler()
230+
{
231+
// Disable SSL certificate validation (not recommended in production!)
232+
return new HttpClientHandler
233+
{
234+
ServerCertificateCustomValidationCallback =
235+
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator,
236+
};
237+
}
238+
}
239+
```
240+
209241
## Next steps
210242

211243
> [!div class="nextstepaction"]

0 commit comments

Comments
 (0)