Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
WebJobs enables applications to run background tasks in the same instance as a web app. The Workflow Studio has four new types of templates based on triggers for the Azure WebJobs. Please consider the description below to choose the appropriate template,
Queue Trigger – The Queue trigger starts the WebJob when a new message is received on a queue.
Timer Trigger – This trigger will start the WebJob based on the timer (Timestamp/CRON) value.
Blob Trigger – Blob Trigger will invoke the WebJob when a file is uploaded to the blob container.
Continuous – This web job will be manually invoked while starting the application and runs continuously.
Anchor | ||||
---|---|---|---|---|
|
Please follow the steps below to create a Web Job based on a Queue Trigger.
Right-click on the package folder you want to create the Web Job. Click on New Extension or Library → Azure Services .Net 6.0
Open the properties window, and select AzWebJob_QueueTrigger in the ServiceType property.
Save the Web Job.
Double click the job in the Solution Explorer to load it into Visual Studio.
Open the Appsettings.Json and update the storage and queue values
AzureWebJobsStorage:
QueueName:
The MyWebJobs.cs file has a default method ProcessQueueMessageAsync which invokes whenever a message is received in the queue. By default, it has the code to log a test message.
Click on build or follow the instructions https://dotnetworkflow.jira.com/wiki/spaces/EDGV21/pages/1606357003/Deployment+Overview#Deploy-to-a-local-folder to deploy the Web Jobs files into a package. You can find the zip of the Web Job inside ..\EmpowerID\WFS\_microservices folder. Look for the zip with the name of the WebJob you created.
Open the Azure portal and navigate to the App Service.
Update the Queue Name in the Application Settings for the App.
Click on Configuration Menu
Click on the Application Settings tab and edit the value for QueueName. Make sure you set the exact value of the key to the value you used in Appsettings.json on step #5.
Click on the WebJobs menu and then the Add ➕ button.
Provide the necessary details for the Job and Click on the Ok to save the WebJob.
Name: Identifier for the WebJob.
File Upload: Deployment files for the WebJob. Choose the zip file you generated by building your project in step #7.
Type: Select job type is ‘Triggered.’
Image Added
After seeing the success message of saving the job, click on the Run button to test it.
Now navigate to the Queue you just created and add Message Text. Click the Ok button to save the message.
Open the Job in the browser & navigate to Logs. You can find the configured message of the previous step in the logs, indicating that you have successfully created a Queue Trigger WebJob.
Anchor | ||||
---|---|---|---|---|
|
Right-click on the package folder you want to create the Web Job. Click on New Extension or Library → Azure Services .Net 6.0
Image AddedOpen the properties window, and select AzWebJob_QueueTrigger in the ServiceType property.
Image AddedSave the Web Job.
Double click the job in the Solution Explorer to load it into Visual Studio.
Open the Appsettings.Json and update the storage setting values. Please ignore the QueueName settings that were required on another WebJobs.
AzureWebJobsStorage :
Image Added
The MyWebJobs.cs file has a default method Run which invokes based on the cron expression passed on the arguments. By default, it has the code to log a text message every five mins. You can change the default cron expression 0 */5 * * * * to 0 */1 * * * * to trigger it every minute.
Image AddedClick on build or follow the instructions https://dotnetworkflow.jira.com/wiki/spaces/EDGV21/pages/1606357003/Deployment+Overview#Deploy-to-a-local-folder to deploy the Web Jobs files into a package. You can find the zip of the Web Job inside ..\EmpowerID\WFS\_microservices folder. Look for the zip with the name of the WebJob you created.
Open the Azure portal and navigate to the App Service that you want to create the WebJob for.
Click on the WebJobs menu and then the Add ➕ button.
Provide the necessary details for the Job and Click on the Ok to save the WebJob.
Name: Identifier for the WebJob.
File Upload: Deployment files for the WebJob. Choose the zip file you generated by building your project in step #7.
Type: Select job type is ‘Triggered.’
Image Added
Once the job is added successfully Click on the ‘Run’ button to run the job manually. Once you have triggered the job, you will see the job listed and running status.
Image AddedImage Added
Now navigate to Job Logs to find if the job ran sucessfully. You can see the information logged from the WebJob.
Image Added
Div | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
IN THIS ARTICLE
|
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|