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
+43-35Lines changed: 43 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,28 +34,31 @@ This article shows you how to deploy WebJobs as a .NET Core console app. To depl
34
34
35
35
## WebJobs NuGet packages
36
36
37
-
1. Install the latest stable 3.x version of the `Microsoft.Azure.WebJobs.Extensions` NuGet package, which includes `Microsoft.Azure.WebJobs`.
37
+
1. Install the latest stable 3.x version of the [`Microsoft.Azure.WebJobs.Extensions` NuGet package](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions/), which includes `Microsoft.Azure.WebJobs`.
38
38
39
-
Here's the **Package Manager Console** command for version 3.0.2:
In this command, replace `<3_X_VERSION>` with a supported version of the package.
46
+
45
47
## Create the Host
46
48
47
49
The host is the runtime container for functions that listens for triggers and calls functions. The following steps create a host that implements [`IHost`](/dotnet/api/microsoft.extensions.hosting.ihost), which is the Generic Host in ASP.NET Core.
48
50
49
-
1. In *Program.cs*, add a `using` statement:
51
+
1. In *Program.cs*, add these `using` statements:
50
52
51
53
```cs
54
+
using System.Threading.Tasks;
52
55
using Microsoft.Extensions.Hosting;
53
56
```
54
57
55
58
1. Replace the `Main` method with the following code:
56
59
57
60
```cs
58
-
static void Main(string[] args)
61
+
static async Task Main()
59
62
{
60
63
var builder = new HostBuilder();
61
64
builder.ConfigureWebJobs(b =>
@@ -65,7 +68,7 @@ The host is the runtime container for functions that listens for triggers and ca
65
68
var host = builder.Build();
66
69
using (host)
67
70
{
68
-
host.Run();
71
+
await host.RunAsync();
69
72
}
70
73
}
71
74
```
@@ -76,12 +79,12 @@ In ASP.NET Core, host configurations are set by calling methods on the [`HostBui
76
79
77
80
In this section, you set up console logging that uses the [ASP.NET Core logging framework](/aspnet/core/fundamentals/logging).
78
81
79
-
1. Install the latest stable version of the `Microsoft.Extensions.Logging.Console` NuGet package, which includes `Microsoft.Extensions.Logging`.
82
+
1. Install 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`.
80
83
81
-
Here's the **Package Manager Console** command for version 2.2.0:
@@ -90,6 +93,8 @@ In this section, you set up console logging that uses the [ASP.NET Core logging
90
93
usingMicrosoft.Extensions.Logging;
91
94
```
92
95
96
+
In this command, replace `<3_X_VERSION>` with a supported 3.x version of the package.
97
+
93
98
1. Call the [`ConfigureLogging`](/dotnet/api/microsoft.aspnetcore.hosting.webhostbuilderextensions.configurelogging) method on [`HostBuilder`](/dotnet/api/microsoft.extensions.hosting.hostbuilder). The [`AddConsole`](/dotnet/api/microsoft.extensions.logging.consoleloggerextensions.addconsole) method adds console logging to the configuration.
94
99
95
100
```cs
@@ -102,7 +107,7 @@ In this section, you set up console logging that uses the [ASP.NET Core logging
102
107
The `Main` methodnowlookslikethis:
103
108
104
109
```cs
105
-
staticvoidMain(string[] args)
110
+
staticasyncTaskMain()
106
111
{
107
112
varbuilder=newHostBuilder();
108
113
builder.ConfigureWebJobs(b=>
@@ -116,7 +121,7 @@ In this section, you set up console logging that uses the [ASP.NET Core logging
116
121
varhost=builder.Build();
117
122
using (host)
118
123
{
119
-
host.Run();
124
+
awaithost.RunAsync();
120
125
}
121
126
}
122
127
```
@@ -134,11 +139,13 @@ Starting with version 3.x, you must explicitly install the Storage binding exten
134
139
135
140
1. Installthelateststableversionofthe [Microsoft.Azure.WebJobs.Extensions.Storage](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage) NuGet package, version 3.x.
136
141
137
-
Here's the **Package Manager Console** command for version 3.0.4:
The `QueueTrigger` attribute tells the runtime to call the function whenever a queue message appears in the `myqueue-items` queue. The `Blob` attribute tells the runtime to use the queue message to read a blob in the *sample-workitems* container. The content of the queue message, passed in to the function in the `myQueueItem` parameter, is the name of the blob.
162
+
The `QueueTrigger` attribute tells the runtime to call the function whenever a queue message appears in the `myqueue-items` queue. The `Blob` attribute tells the runtime to use the queue message to read a blob in the *sample-workitems* container. The name of the blob item in the `samples-workitems` container is obtained directly from the queue trigger as a binding expression (`{queueTrigger}`).
0 commit comments