Skip to content

Commit 09d4319

Browse files
authored
Merge pull request #312945 from v-thpra/tjp-fresh-appsrvc-001
Q&M Freshness - App Service - TJP001
2 parents ac97a6b + 94c3f9b commit 09d4319

1 file changed

Lines changed: 59 additions & 49 deletions

File tree

articles/app-service/webjobs-dotnet-deploy-vs.md

Lines changed: 59 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: Develop and deploy WebJobs using Visual Studio
2+
title: Develop and Deploy WebJobs Using Visual Studio
33
description: Learn how to develop Azure WebJobs in Visual Studio and deploy them to Azure App Service, including creating a scheduled task.
44
author: ggailey777
55
ms.assetid: a3a9d320-1201-4ac8-9398-b4c9535ba755
66
ms.topic: how-to
77
ms.devlang: csharp
88
ms.custom: devx-track-csharp, vs-azure, devx-track-dotnet
9-
ms.date: 06/24/2021
9+
ms.date: 02/10/2026
1010
ms.author: glenga
1111
ms.reviewer: david.ebbo;suwatch;pbatum;naren.soni
1212
ms.service: azure-app-service
@@ -18,7 +18,7 @@ This article explains how to use Visual Studio to deploy a console app project t
1818

1919
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.
2020

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.
2222

2323
## WebJobs as .NET Core console apps
2424

@@ -39,87 +39,94 @@ If you use Visual Studio to deploy a WebJobs-enabled .NET Framework console app
3939

4040
Visual Studio adds the following items to a WebJobs-enabled project:
4141

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.
4444

45-
![Diagram showing what's added to a console app to enable deployment as a WebJob](./media/webjobs-dotnet-deploy-vs/convert.png)
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.":::
4646

4747
You can add these items to an existing console app project or use a template to create a new WebJobs-enabled console app project.
4848

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.
5050

51-
![Diagram showing WebJob project linking to web project](./media/webjobs-dotnet-deploy-vs/link.png)
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.":::
5252

5353
### Prerequisites
5454

5555
Install Visual Studio 2022 with the [Azure development workload](/visualstudio/install/install-visual-studio#step-4---choose-workloads).
5656

57-
### <a id="convert"></a> Enable WebJobs deployment for an existing console app project
57+
### Enable WebJobs deployment for an existing console app project
5858

5959
You have two options:
6060

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).
6262

6363
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.
6464

65-
* [Enable deployment without a web project](#convertnolink).
65+
- [Enable deployment without a web project](#enable-webjobs-deployment-without-a-web-project).
6666

6767
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.
6868

69-
#### <a id="convertlink"></a> Enable automatic WebJobs deployment with a web project
69+
#### Enable automatic WebJobs deployment with a web project
7070

7171
1. Right-click the web project in **Solution Explorer**, and then select **Add** > **Existing Project as Azure WebJob**.
7272

73-
![Existing Project as Azure WebJob](./media/webjobs-dotnet-deploy-vs/eawj.png)
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.":::
7474

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.
7778

78-
![Selecting project in Add Azure WebJob dialog box](./media/webjobs-dotnet-deploy-vs/aaw1.png)
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
8084

81-
#### <a id="convertnolink"></a> Enable WebJobs deployment without a web project
8285
1. Right-click the console app project in **Solution Explorer**, and then select **Publish as Azure WebJob**.
8386

84-
![Publish as Azure WebJob](./media/webjobs-dotnet-deploy-vs/paw.png)
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.":::
8588

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**.
8892

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).
9094

91-
### <a id="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
9396

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)
95100

96101
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)
98104

99105
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.
100106

101107
> [!NOTE]
102108
> 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-
>
105109
106-
#### <a id="createnolink"></a> Use the WebJobs new-project template for an independent WebJob
110+
#### Use the WebJobs new-project template for an independent WebJob
111+
107112
1. Select **File** > **New** > **Project**. In the **Create a new project** dialog box, search for and select **Azure WebJob (.NET Framework)** for C#.
108113

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
110117

111-
#### <a id="createlink"></a> Use the WebJobs new-project template for a WebJob linked to a web project
112118
1. Right-click the web project in **Solution Explorer**, and then select **Add** > **New Azure WebJob Project**.
113119

114-
![New Azure WebJob Project menu entry](./media/webjobs-dotnet-deploy-vs/nawj.png)
120+
:::image type="content" source="./media/webjobs-dotnet-deploy-vs/nawj.png" alt-text="Screenshot showing how to add a new Azure WebJob project.":::
115121

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**.
125+
118126

127+
### webjob-publish-settings.json file
119128

120-
### <a id="publishsettings"></a>webjob-publish-settings.json file
121-
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:
123130

124131
```json
125132
{
@@ -135,7 +142,8 @@ and stores scheduling information in a *webjob-publish-settings.json* file in th
135142

136143
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.
137144

138-
### <a id="webjobslist"></a>webjobs-list.json file
145+
### webjobs-list.json file
146+
139147
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:
140148

141149
```json
@@ -154,29 +162,31 @@ When you link a WebJobs-enabled project to a web project, Visual Studio stores t
154162

155163
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).
156164

157-
### <a id="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.
159168

160169
To deploy a WebJobs project by itself, right-click the project in **Solution Explorer** and select **Publish as Azure WebJob**.
161170

162-
![Publish as Azure WebJob](./media/webjobs-dotnet-deploy-vs/paw.png)
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.":::
163172

164173
For an independent WebJob, the same **Publish Web** wizard that is used for web projects appears, but with fewer settings available to change.
165174

166-
### <a id="configure"></a>Add Azure WebJob dialog box
175+
### Add Azure WebJob dialog box
176+
167177
The **Add Azure WebJob** dialog box lets you enter the WebJob name and the run mode setting for your WebJob.
168178

169-
![Add Azure WebJob dialog box](./media/webjobs-dotnet-deploy-vs/aaw2.png)
179+
:::image type="content" source="./media/webjobs-dotnet-deploy-vs/aaw2.png" alt-text="Screenshot of the Add Azure WebJob dialog box.":::
170180

171181
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).
172182

173183
WebJob deployment information:
174184

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/).
176186

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.
178188

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.
180190

181191
## WebJob types
182192

@@ -212,7 +222,7 @@ WebJobs uses the same CRON expressions for scheduling as the timer trigger in Az
212222

213223
#### settings.job reference
214224

215-
The following settings are supported by WebJobs:
225+
WebJobs supports the following settings in the **settings.job** file:
216226

217227
| **Setting** | **Type** | **Description** |
218228
| ----------- | --------- | --------------- |
@@ -225,15 +235,15 @@ The following settings are supported by WebJobs:
225235

226236
If you enable **Always on** in Azure, you can use Visual Studio to change the WebJob to run continuously:
227237

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).
229239

230240
1. In **Solution Explorer**, right-click the project and select **Publish**.
231241

232242
1. In the **Settings** section, choose **Show all settings**.
233243

234244
1. In the **Profile settings** dialog box, choose **Continuous** for **WebJob Type**, and then choose **Save**.
235245

236-
![Publish Settings dialog box for a WebJob](./media/webjobs-dotnet-deploy-vs/publish-settings.png)
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.":::
237247

238248
1. Select **Publish** in the **Publish** tab to republish the WebJob with the updated settings.
239249

0 commit comments

Comments
 (0)