Skip to content

Commit df91c04

Browse files
committed
Refine start-up code considerations and clarify dependency injection usage in the isolated worker model guide
1 parent d3f0818 commit df91c04

1 file changed

Lines changed: 12 additions & 24 deletions

File tree

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

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -154,30 +154,18 @@ The following code shows an example of a [HostBuilder] pipeline:
154154

155155
:::code language="csharp" source="~/azure-functions-dotnet-worker/samples/FunctionApp/Program.cs" id="docsnippet_startup":::
156156

157-
> [!NOTE]
158-
> The above example from [HostBuilder] pipeline has a line demonstrating dependency injection:
159-
>
160-
> ```csharp
161-
> s.AddSingleton<IHttpResponderService, DefaultHttpResponderService>();
162-
> ```
163-
>
164-
> **You can safely ignore this line.** This is sample code only. `IHttpResponderService` and `DefaultHttpResponderService`
165-
> are not built-in Azure Function SDK types and are not relevant to a production application.
166-
167-
This code requires `using Microsoft.Extensions.DependencyInjection;`.
168-
169-
Before calling `Build()` on the `IHostBuilder`, you should:
170-
171-
- Call either `ConfigureFunctionsWebApplication()` if you're using [ASP.NET Core integration](#aspnet-core-integration) or `ConfigureFunctionsWorkerDefaults()` otherwise. See [HTTP trigger](#http-trigger) for details on these options.
172-
If you're writing your application using F#, some trigger and binding extensions require extra configuration. See the setup documentation for the [Blobs extension][fsharp-blobs], the [Tables extension][fsharp-tables], and the [Cosmos DB extension][fsharp-cosmos] when you plan to use these extensions in an F# app.
173-
- Configure any services or app configuration your project requires. See [Configuration](#configuration) for details.
174-
If you plan to use Application Insights, you need to call `AddApplicationInsightsTelemetryWorkerService()` and `ConfigureFunctionsApplicationInsights()` in the `ConfigureServices()` delegate. See [Application Insights](#application-insights) for details.
175-
176-
If your project targets .NET Framework 4.8, you also need to add `FunctionsDebugger.Enable();` before creating the HostBuilder. It should be the first line of your `Main()` method. For more information, see [Debugging when targeting .NET Framework](#debugging-when-targeting-net-framework).
177-
178-
The [HostBuilder] builds and returns a fully initialized [`IHost`][IHost] instance. You run this instance asynchronously to start your function app.
179-
180-
:::code language="csharp" source="~/azure-functions-dotnet-worker/samples/FunctionApp/Program.cs" id="docsnippet_host_run":::
157+
Considerations for your start-up code:
158+
159+
- Before calling `Build()` on the `IHostBuilder`, you should:
160+
- Call either `ConfigureFunctionsWebApplication()` if you're using [ASP.NET Core integration](#aspnet-core-integration) or `ConfigureFunctionsWorkerDefaults()` otherwise. See [HTTP trigger](#http-trigger) for details on these options.
161+
If you're writing your application using F#, some trigger and binding extensions require extra configuration. See the setup documentation for the [Blobs extension][fsharp-blobs], the [Tables extension][fsharp-tables], and the [Cosmos DB extension][fsharp-cosmos] when you plan to use these extensions in an F# app.
162+
- Configure any services or app configuration your project requires. See [Configuration](#configuration) for details.
163+
If you plan to use Application Insights, you need to call `AddApplicationInsightsTelemetryWorkerService()` and `ConfigureFunctionsApplicationInsights()` in the `ConfigureServices()` delegate. See [Application Insights](#application-insights) for details.
164+
- If your project targets .NET Framework 4.8, you also need to add `FunctionsDebugger.Enable();` before creating the HostBuilder. It should be the first line of your `Main()` method. For more information, see [Debugging when targeting .NET Framework](#debugging-when-targeting-net-framework).
165+
- This example includes dependency injection, which is optional for your start-up code. Dependency injection also requires `using Microsoft.Extensions.DependencyInjection;`. For more information, see [Dependency injection](#dependency-injection).
166+
- The [HostBuilder] builds and returns a fully initialized [`IHost`][IHost] instance. You run this instance asynchronously to start your function app.
167+
168+
:::code language="csharp" source="~/azure-functions-dotnet-worker/samples/FunctionApp/Program.cs" id="docsnippet_host_run":::
181169

182170
---
183171

0 commit comments

Comments
 (0)