Skip to content

Commit dc4c9c5

Browse files
author
Glenn Gailey
committed
Switch to async main
1 parent ce5a804 commit dc4c9c5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

articles/app-service/webjobs-sdk-get-started.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,17 @@ This article shows you how to deploy WebJobs as a .NET Core console app. To depl
4848
4949
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.
5050
51-
1. In *Program.cs*, add a `using` statement:
51+
1. In *Program.cs*, add these `using` statements:
5252
5353
```cs
54+
using System.Threading.Tasks;
5455
using Microsoft.Extensions.Hosting;
5556
```
5657
5758
1. Replace the `Main` method with the following code:
5859
5960
```cs
60-
static void Main(string[] args)
61+
static async Task Main()
6162
{
6263
var builder = new HostBuilder();
6364
builder.ConfigureWebJobs(b =>
@@ -67,7 +68,7 @@ The host is the runtime container for functions that listens for triggers and ca
6768
var host = builder.Build();
6869
using (host)
6970
{
70-
host.Run();
71+
await host.RunAsync();
7172
}
7273
}
7374
```
@@ -106,7 +107,7 @@ In this section, you set up console logging that uses the [ASP.NET Core logging
106107
The `Main` method now looks like this:
107108

108109
```cs
109-
static void Main(string[] args)
110+
static async Task Main()
110111
{
111112
var builder = new HostBuilder();
112113
builder.ConfigureWebJobs(b =>
@@ -120,7 +121,7 @@ In this section, you set up console logging that uses the [ASP.NET Core logging
120121
var host = builder.Build();
121122
using (host)
122123
{
123-
host.Run();
124+
await host.RunAsync();
124125
}
125126
}
126127
```
@@ -369,7 +370,7 @@ To take advantage of [Application Insights](../azure-monitor/app/app-insights-ov
369370
1. Open *Program.cs* and replace the code in the `Main` method with the following code:
370371

371372
```cs
372-
static void Main(string[] args)
373+
static async Task Main()
373374
{
374375
var builder = new HostBuilder();
375376
builder.UseEnvironment(EnvironmentName.Development);
@@ -392,7 +393,7 @@ To take advantage of [Application Insights](../azure-monitor/app/app-insights-ov
392393
var host = builder.Build();
393394
using (host)
394395
{
395-
host.Run();
396+
await host.RunAsync();
396397
}
397398
}
398399
```

0 commit comments

Comments
 (0)