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
Copy file name to clipboardExpand all lines: articles/app-service/webjobs-sdk-get-started.md
+61-39Lines changed: 61 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: Learn how to enable your web apps to run background tasks. Use this
4
4
author: ggailey777
5
5
ms.devlang: csharp
6
6
ms.custom: devx-track-csharp
7
-
ms.date: 06/25/2021
7
+
ms.date: 01/17/2025
8
8
ms.author: glenga
9
9
ms.topic: tutorial
10
10
@@ -15,7 +15,7 @@ ms.topic: tutorial
15
15
16
16
Get started with the Azure WebJobs SDK for Azure App Service to enable your web apps to run background tasks, scheduled tasks, and respond to events.
17
17
18
-
Use Visual Studio 2022 to create a .NET Core console app that uses the WebJobs SDK to respond to Azure Storage Queue messages, run the project locally, and finally deploy it to Azure.
18
+
Use Visual Studio 2022 to create a .NET 8 console app that uses the WebJobs SDK to respond to Azure Storage Queue messages, run the project locally, and finally deploy it to Azure.
19
19
20
20
In this tutorial, you will learn how to:
21
21
@@ -37,7 +37,7 @@ In this tutorial, you will learn how to:
37
37
In this section, you start by creating a project in Visual Studio 2022. Next, you'll add tools for Azure development, code publishing, and functions that listen for triggers and call functions. Last, you'll set up console logging that disables a legacy monitoring tool and enables a console provider with default filtering.
38
38
39
39
>[!NOTE]
40
-
>The procedures in this article are verified for creating a .NET Core console app that runs on .NET 6.0.
40
+
>The procedures in this article are verified for creating a C# console app that runs on .NET 8.0.
41
41
42
42
### Create a project
43
43
@@ -64,6 +64,9 @@ Install the latest WebJobs NuGet package. This package includes Microsoft.Azure.
>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.
69
+
67
70
5. In the **Package Manager Console**, execute the command. The extension list appears and automatically installs.
68
71
69
72
### Create the Host
@@ -109,10 +112,10 @@ Set up console logging that uses the [ASP.NET Core logging framework](/aspnet/co
109
112
110
113
1. Get the latest stable version of the [`Microsoft.Extensions.Logging.Console` NuGet package](https://www.nuget.org/packages/Microsoft.Extensions.Logging.Console/), which includes `Microsoft.Extensions.Logging`.
111
114
112
-
2. In the following command, replace `<6_X_VERSION>` with the current version number you found in step 1. Each type of NuGet Package has a unique version number.
115
+
2. In the following command, replace `<9_X_VERSION>` with the current version number you found in step 1. Each type of NuGet Package has a unique version number.
3. In the **Package Manager Console**, fill in the current version number and execute the command. The extension list appears and automatically installs.
118
121
@@ -126,24 +129,30 @@ Set up console logging that uses the [ASP.NET Core logging framework](/aspnet/co
126
129
```cs
127
130
builder.ConfigureLogging((context, b) =>
128
131
{
129
-
b.AddConsole();
132
+
b.SetMinimumLevel(LogLevel.Error);
133
+
b.AddFilter("Function", LogLevel.Information);
134
+
b.AddFilter("Host", LogLevel.Debug);
135
+
b.AddConsole();
130
136
});
131
137
```
132
138
133
-
The `Main` methodnowlookslikethis:
139
+
Thisaddsloggingthatcaptureslogoutputfor function executions at the `Information` level, the host at the `Debug` level, and the `error` level for all other components. The `Main` method now looks like this:
134
140
135
141
```cs
136
142
static async Task Main()
137
143
{
138
144
varbuilder=newHostBuilder();
139
145
builder.ConfigureWebJobs(b=>
140
-
{
141
-
b.AddAzureStorageCoreServices();
142
-
});
146
+
{
147
+
b.AddAzureStorageCoreServices();
148
+
});
143
149
builder.ConfigureLogging((context, b) =>
144
-
{
145
-
b.AddConsole();
146
-
});
150
+
{
151
+
b.SetMinimumLevel(LogLevel.Error);
152
+
b.AddFilter("Function", LogLevel.Information);
153
+
b.AddFilter("Host", LogLevel.Debug);
154
+
b.AddConsole();
155
+
});
147
156
varhost=builder.Build();
148
157
using (host)
149
158
{
@@ -170,7 +179,7 @@ In this section, you create a function triggered by messages in an Azure Storage
>Beginningwith5.x, Microsoft.Azure.WebJobs.Extensions.Storagehasbeen [splitbystorageservice](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage/CHANGELOG.md#major-changes-and-features) and has migrated the `AddAzureStorage()` extension method by service type.
182
+
>Beginningwith5.x, Microsoft.Azure.WebJobs.Extensions.Storagehasbeen [splitbystorageservice](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage/CHANGELOG.md#major-changes-and-features) and has migrated the `AddAzureStorage()` extension method by service type. This version also requires you to update the version of the `Microsoft.Azure.WebJobs.Host.Storage` assembly used by the SDK.
174
183
175
184
1. Getthelateststableversionofthe [Microsoft.Azure.WebJobs.Extensions.Storage](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage) NuGet package, version 5.x.
176
185
@@ -179,8 +188,15 @@ Starting with version 3 of the WebJobs SDK, to connect to Azure Storage services
0 commit comments