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
@@ -18,7 +18,7 @@ This article explains how to use Visual Studio to deploy a console app project t
18
18
19
19
You can choose to develop a WebJob that runs as either a [.NET Core app](#webjobs-as-net-core-console-apps) or a [.NET Framework app](#webjobs-as-net-framework-console-apps). Version 3.x of the [Azure WebJobs SDK](webjobs-sdk-how-to.md) lets you develop WebJobs that run as either .NET Core apps or .NET Framework apps, while version 2.x supports only the .NET Framework. The way that you deploy a WebJobs project is different for .NET Core projects than for .NET Framework projects.
20
20
21
-
You can publish multiple WebJobs to a single web app, provided that each WebJob in a web app has a unique name.
21
+
You can publish multiple WebJobs to a single web app, if each WebJob in the web app has a unique name.
22
22
23
23
## WebJobs as .NET Core console apps
24
24
@@ -39,87 +39,94 @@ If you use Visual Studio to deploy a WebJobs-enabled .NET Framework console app
39
39
40
40
Visual Studio adds the following items to a WebJobs-enabled project:
41
41
42
-
* The [Microsoft.Web.WebJobs.Publish](https://www.nuget.org/packages/Microsoft.Web.WebJobs.Publish/) NuGet package.
43
-
* A [webjob-publish-settings.json](#publishsettings) file that contains deployment and scheduler settings.
42
+
- The [Microsoft.Web.WebJobs.Publish](https://www.nuget.org/packages/Microsoft.Web.WebJobs.Publish/) NuGet package.
43
+
- A [webjob-publish-settings.json](#webjob-publish-settingsjson-file) file that contains deployment and scheduler settings.
44
44
45
-

45
+
:::image type="content" source="./media/webjobs-dotnet-deploy-vs/convert.png" alt-text="Diagram showing the NuGet package and WebJob publish settings file being added to a console app to enable deployment as a WebJob.":::
46
46
47
47
You can add these items to an existing console app project or use a template to create a new WebJobs-enabled console app project.
48
48
49
-
Deploy a project as a WebJob by itself, or link it to a web project so that it automatically deploys whenever you deploy the web project. To link projects, Visual Studio includes the name of the WebJobs-enabled project in a [webjobs-list.json](#webjobslist) file in the web project.
49
+
Deploy a project as a WebJob by itself, or link it to a web project so that it automatically deploys whenever you deploy the web project. To link projects, Visual Studio includes the name of the WebJobs-enabled project in a [webjobs-list.json](#webjobs-listjson-file) file in the web project.
50
50
51
-

51
+
:::image type="content" source="./media/webjobs-dotnet-deploy-vs/link.png" alt-text="Diagram showing that a WebJobs project is linked to a web project when its name is included in the the webjobs-list.json file.":::
52
52
53
53
### Prerequisites
54
54
55
55
Install Visual Studio 2022 with the [Azure development workload](/visualstudio/install/install-visual-studio#step-4---choose-workloads).
56
56
57
-
### <aid="convert"></a> Enable WebJobs deployment for an existing console app project
57
+
### Enable WebJobs deployment for an existing console app project
58
58
59
59
You have two options:
60
60
61
-
*[Enable automatic deployment with a web project](#convertlink).
61
+
-[Enable automatic deployment with a web project](#enable-automatic-webjobs-deployment-with-a-web-project).
62
62
63
63
Configure an existing console app project so that it automatically deploys as a WebJob when you deploy a web project. Use this option when you want to run your WebJob in the same web app in which you run the related web application.
64
64
65
-
*[Enable deployment without a web project](#convertnolink).
65
+
-[Enable deployment without a web project](#enable-webjobs-deployment-without-a-web-project).
66
66
67
67
Configure an existing console app project to deploy as a WebJob by itself, without a link to a web project. Use this option when you want to run a WebJob in a web app by itself, with no web application running in the web app. You might want to do so to scale your WebJob resources independently of your web application resources.
68
68
69
-
#### <aid="convertlink"></a> Enable automatic WebJobs deployment with a web project
69
+
#### Enable automatic WebJobs deployment with a web project
70
70
71
71
1. Right-click the web project in **Solution Explorer**, and then select **Add** > **Existing Project as Azure WebJob**.
72
72
73
-

73
+
:::image type="content" source="./media/webjobs-dotnet-deploy-vs/eawj.png" alt-text="Screenshot showing how to add an existing project as an Azure WebJob.":::
74
74
75
-
The [Add Azure WebJob](#configure) dialog box appears.
76
-
2. In the **Project name** drop-down list, select the console app project to add as a WebJob.
75
+
The [Add Azure WebJob](#add-azure-webjob-dialog-box) dialog box appears.
76
+
77
+
1. In the **Project name** drop-down list, select the console app project to add as a WebJob.
77
78
78
-

79
-
3. Complete the [Add Azure WebJob](#configure) dialog box, and then select **OK**.
79
+
:::image type="content" source="./media/webjobs-dotnet-deploy-vs/aaw1.png" alt-text="Screenshot showing how to select a project in the Add Azure WebJob dialog box.":::
80
+
81
+
1. Complete the [Add Azure WebJob](#add-azure-webjob-dialog-box) dialog box, and then select **OK**.
82
+
83
+
#### Enable WebJobs deployment without a web project
80
84
81
-
#### <aid="convertnolink"></a> Enable WebJobs deployment without a web project
82
85
1. Right-click the console app project in **Solution Explorer**, and then select **Publish as Azure WebJob**.
83
86
84
-

87
+
:::image type="content" source="./media/webjobs-dotnet-deploy-vs/paw.png" alt-text="Screenshot showing how to select Publish as Azure WebJob in the Solution Explorer.":::
85
88
86
-
The [Add Azure WebJob](#configure) dialog box appears, with the project selected in the **Project name** box.
87
-
2. Complete the [Add Azure WebJob](#configure) dialog box, and then select **OK**.
89
+
The **Add Azure WebJob** dialog box appears, with the project selected in the **Project name** box.
90
+
91
+
1. Complete the [Add Azure WebJob](#add-azure-webjob-dialog-box) dialog box, and then select **OK**.
88
92
89
-
The **Publish Web** wizard appears. If you don't want to publish immediately, close the wizard. The settings that you've entered are saved for when you do want to [deploy the project](#deploy).
93
+
The **Publish Web** wizard appears. If you don't want to publish immediately, close the wizard. The settings that you enter are saved for when you do want to [deploy the project](#deploy-a-webjobs-project).
90
94
91
-
### <aid="create"></a>Create a new WebJobs-enabled project
92
-
To create a new WebJobs-enabled project, use the console app project template and enable WebJobs deployment as explained in [the previous section](#convert). As an alternative, you can use the WebJobs new-project template:
95
+
### Create a new WebJobs-enabled project
93
96
94
-
*[Use the WebJobs new-project template for an independent WebJob](#createnolink)
97
+
To create a new WebJobs-enabled project, use the console app project template and enable WebJobs deployment as explained in [the previous section](#enable-webjobs-deployment-for-an-existing-console-app-project). As an alternative, you can use the WebJobs new-project template:
98
+
99
+
-[Use the WebJobs new-project template for an independent WebJob](#use-the-webjobs-new-project-template-for-an-independent-webjob)
95
100
96
101
Create a project and configure it to deploy by itself as a WebJob, with no link to a web project. Use this option when you want to run a WebJob in a web app by itself, with no web application running in the web app. You might want to do so to scale your WebJob resources independently of your web application resources.
97
-
*[Use the WebJobs new-project template for a WebJob linked to a web project](#createlink)
102
+
103
+
-[Use the WebJobs new-project template for a WebJob linked to a web project](#use-the-webjobs-new-project-template-for-a-webjob-linked-to-a-web-project)
98
104
99
105
Create a project that is configured to deploy automatically as a WebJob when you deploy a web project in the same solution. Use this option when you want to run your WebJob in the same web app in which you run the related web application.
100
106
101
107
> [!NOTE]
102
108
> The WebJobs new-project template automatically installs NuGet packages and includes code in *Program.cs* for the [WebJobs SDK](./webjobs-sdk-get-started.md). If you don't want to use the WebJobs SDK, remove or change the `host.RunAndBlock` statement in *Program.cs*.
103
-
>
104
-
>
105
109
106
-
#### <aid="createnolink"></a> Use the WebJobs new-project template for an independent WebJob
110
+
#### Use the WebJobs new-project template for an independent WebJob
111
+
107
112
1. Select **File** > **New** > **Project**. In the **Create a new project** dialog box, search for and select **Azure WebJob (.NET Framework)** for C#.
108
113
109
-
2. Follow the previous directions to [make the console app project an independent WebJobs project](#convertnolink).
114
+
1. Follow the previous directions to [make the console app project an independent WebJobs project](#enable-webjobs-deployment-without-a-web-project).
115
+
116
+
#### Use the WebJobs new-project template for a WebJob linked to a web project
110
117
111
-
#### <aid="createlink"></a> Use the WebJobs new-project template for a WebJob linked to a web project
112
118
1. Right-click the web project in **Solution Explorer**, and then select **Add** > **New Azure WebJob Project**.
113
119
114
-

120
+
:::image type="content" source="./media/webjobs-dotnet-deploy-vs/nawj.png" alt-text="Screenshot showing how to add a new Azure WebJob project.":::
115
121
116
-
The [Add Azure WebJob](#configure) dialog box appears.
117
-
2. Complete the [Add Azure WebJob](#configure) dialog box, and then select **OK**.
122
+
The **Add Azure WebJob** dialog box appears.
123
+
124
+
1. Complete the [Add Azure WebJob](#add-azure-webjob-dialog-box) dialog box, and then select **OK**.
When you configure a console app for WebJobs deployment, Visual Studio installs the [Microsoft.Web.WebJobs.Publish](https://www.nuget.org/packages/Microsoft.Web.WebJobs.Publish/) NuGet package
122
-
and stores scheduling information in a *webjob-publish-settings.json* file in the project *Properties* folder of the WebJobs project. Here is an example of that file:
129
+
When you configure a console app for WebJobs deployment, Visual Studio installs the [Microsoft.Web.WebJobs.Publish](https://www.nuget.org/packages/Microsoft.Web.WebJobs.Publish/) NuGet package and stores scheduling information in a *webjob-publish-settings.json* file in the project *Properties* folder of the WebJobs project. Here's an example of that file:
123
130
124
131
```json
125
132
{
@@ -135,7 +142,8 @@ and stores scheduling information in a *webjob-publish-settings.json* file in th
135
142
136
143
You can edit this file directly, and Visual Studio provides IntelliSense. The file schema is stored at [https://schemastore.org](http://schemastore.org/schemas/json/webjob-publish-settings.json) and can be viewed there.
137
144
138
-
### <aid="webjobslist"></a>webjobs-list.json file
145
+
### webjobs-list.json file
146
+
139
147
When you link a WebJobs-enabled project to a web project, Visual Studio stores the name of the WebJobs project in a *webjobs-list.json* file in the web project's *Properties* folder. The list might contain multiple WebJobs projects, as shown in the following example:
140
148
141
149
```json
@@ -154,29 +162,31 @@ When you link a WebJobs-enabled project to a web project, Visual Studio stores t
154
162
155
163
You can edit this file directly in Visual Studio, with IntelliSense. The file schema is stored at [https://schemastore.org](http://schemastore.org/schemas/json/webjobs-list.json).
156
164
157
-
### <aid="deploy"></a>Deploy a WebJobs project
158
-
A WebJobs project that you've linked to a web project deploys automatically with the web project. For information about web project deployment, see **How-to guides** > **Deploy the app** in the left navigation.
165
+
### Deploy a WebJobs project
166
+
167
+
A WebJobs project that you link to a web project deploys automatically with the web project. For information about web project deployment, see **How-to guides** > **Deploy the app** in the left navigation.
159
168
160
169
To deploy a WebJobs project by itself, right-click the project in **Solution Explorer** and select **Publish as Azure WebJob**.
161
170
162
-

171
+
:::image type="content" source="./media/webjobs-dotnet-deploy-vs/paw.png" alt-text="Screenshot showing how to select Publish as Azure WebJob in the Solution Explorer.":::
163
172
164
173
For an independent WebJob, the same **Publish Web** wizard that is used for web projects appears, but with fewer settings available to change.
:::image type="content" source="./media/webjobs-dotnet-deploy-vs/aaw2.png" alt-text="Screenshot of the Add Azure WebJob dialog box.":::
170
180
171
181
Some of the fields in this dialog box correspond to fields on the **Add WebJob** dialog box of the Azure portal. For more information, see [Run background tasks with WebJobs in Azure App Service](webjobs-create.md).
172
182
173
183
WebJob deployment information:
174
184
175
-
* For information about command-line deployment, see [Enabling Command-line or Continuous Delivery of Azure WebJobs](https://azure.microsoft.com/blog/enabling-command-line-or-continuous-delivery-of-azure-webjobs/).
185
+
- For information about command-line deployment, see [Enabling Command-line or Continuous Delivery of Azure WebJobs](https://azure.microsoft.com/blog/enabling-command-line-or-continuous-delivery-of-azure-webjobs/).
176
186
177
-
* If you deploy a WebJob, and then decide you want to change the type of WebJob and redeploy, delete the *webjobs-publish-settings.json* file. Doing so causes Visual Studio to redisplay the publishing options, so you can change the type of WebJob.
187
+
- If you deploy a WebJob, and then decide you want to change the type of WebJob and redeploy, delete the *webjobs-publish-settings.json* file. Doing so causes Visual Studio to redisplay the publishing options, so you can change the type of WebJob.
178
188
179
-
* If you deploy a WebJob and later change the run mode from continuous to non-continuous or vice versa, Visual Studio creates a new WebJob in Azure when you redeploy. If you change other scheduling settings, but leave run mode the same or switch between Scheduled and On Demand, Visual Studio updates the existing job instead of creating a new one.
189
+
- If you deploy a WebJob, and later change the run mode between *continuous* and *triggered*, Visual Studio creates a new WebJob in Azure when you redeploy. If you change other scheduling settings, but leave run mode the same or switch between Scheduled and On Demand, Visual Studio updates the existing job instead of creating a new one.
180
190
181
191
## WebJob types
182
192
@@ -212,7 +222,7 @@ WebJobs uses the same CRON expressions for scheduling as the timer trigger in Az
212
222
213
223
#### settings.job reference
214
224
215
-
The following settings are supported by WebJobs:
225
+
WebJobs supports the following settings in the **settings.job** file:
216
226
217
227
|**Setting**|**Type**|**Description**|
218
228
| ----------- | --------- | --------------- |
@@ -225,15 +235,15 @@ The following settings are supported by WebJobs:
225
235
226
236
If you enable **Always on** in Azure, you can use Visual Studio to change the WebJob to run continuously:
227
237
228
-
1. If you haven't already done so,[publish the project to Azure](#deploy-to-azure-app-service).
238
+
1. If the project isn't published already, then[publish the project to Azure](#deploy-to-azure-app-service).
229
239
230
240
1. In **Solution Explorer**, right-click the project and select **Publish**.
231
241
232
242
1. In the **Settings** section, choose **Show all settings**.
233
243
234
244
1. In the **Profile settings** dialog box, choose **Continuous** for **WebJob Type**, and then choose **Save**.
235
245
236
-

246
+
:::image type="content" source="./media/webjobs-dotnet-deploy-vs/publish-settings.png" alt-text="Screenshot showing the Publish Settings dialog box for a WebJob.":::
237
247
238
248
1. Select **Publish** in the **Publish** tab to republish the WebJob with the updated settings.
0 commit comments