You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -3,7 +3,7 @@ title: Tutorial for event-driven background processing with the WebJobs SDK
3
3
description: Learn how to enable your web apps to run background tasks. Use this tutorial to get started with the WebJobs SDK.
4
4
author: ggailey777
5
5
ms.devlang: csharp
6
-
ms.date: 01/17/2025
6
+
ms.date: 03/12/2026
7
7
ms.author: glenga
8
8
ms.topic: tutorial
9
9
@@ -37,6 +37,7 @@ You learn how to:
37
37
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn).
38
38
39
39
## Create a console app
40
+
40
41
In this section, you start by creating a project in Visual Studio 2022. Next, you add tools for Azure development, code publishing, and functions that listen for triggers and call functions. Last, you set up console logging that disables a legacy monitoring tool and enables a console provider with default filtering.
41
42
42
43
> [!NOTE]
@@ -64,11 +65,12 @@ Install the latest WebJobs NuGet package. This package includes Microsoft.Azure.
64
65
65
66
1. In the following command, replace `<4_X_VERSION>` with the current version number you found in step 1.
> The sample code in this article works with package versions 4.x. Make sure you use a 4.x version because you get build errors when using package versions 5.x.
> The sample code in this article works with package versions 4.x. Make sure you use a 4.x version because you get build errors when using package versions 5.x.
72
74
73
75
1. In the **Package Manager Console**, execute the command. The extension list appears and automatically installs.
74
76
@@ -78,34 +80,34 @@ The host is the runtime container for functions that listens for triggers and ca
78
80
79
81
1. Select the **Program.cs** tab, remove the existing contents, and add these `using` statements:
80
82
81
-
```cs
82
-
using System.Threading.Tasks;
83
-
using Microsoft.Extensions.Hosting;
84
-
```
83
+
```cs
84
+
usingSystem.Threading.Tasks;
85
+
usingMicrosoft.Extensions.Hosting;
86
+
```
85
87
86
88
1. Also under **Program.cs**, add the following code:
87
89
88
-
```cs
89
-
namespace WebJobsSDKSample
90
-
{
91
-
class Program
92
-
{
93
-
static async Task Main()
94
-
{
95
-
var builder = new HostBuilder();
96
-
builder.ConfigureWebJobs(b =>
97
-
{
98
-
b.AddAzureStorageCoreServices();
99
-
});
100
-
var host = builder.Build();
101
-
using (host)
102
-
{
103
-
await host.RunAsync();
104
-
}
105
-
}
106
-
}
107
-
}
108
-
```
90
+
```cs
91
+
namespaceWebJobsSDKSample
92
+
{
93
+
classProgram
94
+
{
95
+
staticasyncTaskMain()
96
+
{
97
+
varbuilder=newHostBuilder();
98
+
builder.ConfigureWebJobs(b=>
99
+
{
100
+
b.AddAzureStorageCoreServices();
101
+
});
102
+
varhost=builder.Build();
103
+
using (host)
104
+
{
105
+
awaithost.RunAsync();
106
+
}
107
+
}
108
+
}
109
+
}
110
+
```
109
111
110
112
In ASP.NET Core, host configurations are set by calling methods on the [`HostBuilder`](/dotnet/api/microsoft.extensions.hosting.hostbuilder) instance. For more information, see [.NET Generic Host](/aspnet/core/fundamentals/host/generic-host). The `ConfigureWebJobs` extension method initializes the WebJobs host. In `ConfigureWebJobs`, initialize specific binding extensions, such as the Storage binding extension, and set properties of those extensions.
111
113
@@ -188,61 +190,61 @@ Starting with version 3 of the WebJobs SDK, to connect to Azure Storage services
Runningin [developmentmode](webjobs-sdk-how-to.md#host-development-settings) reducesthe [queuepollingexponentialbackoff](../azure-functions/functions-bindings-storage-queue-trigger.md?tabs=csharp#polling-algorithm). Thispollingalgorithmcansignificantlydelaytheamountoftimeittakesfortheruntimetofindthemessageandinvokethefunction. Youshouldremovethislineofcodeorswitch to `Production` when you're done with development and testing.
220
+
Runningin [developmentmode](webjobs-sdk-how-to.md#host-development-settings) reducesthe [queuepollingexponentialbackoff](../azure-functions/functions-bindings-storage-queue-trigger.md?tabs=csharp#polling-algorithm). Thispollingalgorithmcansignificantlydelaytheamountoftimeittakesfortheruntimetofindthemessageandinvokethefunction. Youshouldremovethislineofcodeorswitch to `Production` when you're done with development and testing.
219
221
220
-
The `Main` method should now look like the following example:
222
+
The `Main` method should now look like the following example:
The `message` parameterdoesn't have to be a string. You can also bind to a JSON object, a byte array, or a [CloudQueueMessage](/dotnet/api/microsoft.azure.storage.queue.cloudqueuemessage) object. [See Queue trigger usage](../azure-functions/functions-bindings-storage-queue-trigger.md?tabs=csharp#usage). Each binding type (such as queues, blobs, or tables) has a different set of parameter types that you can bind to.
276
278
@@ -298,11 +300,11 @@ The WebJobs SDK looks for the storage connection string in the Application Setti
0 commit comments