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. The triggers determine which event invokes the WebJob. Please consider the different available triggers 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.

Info

In this article, the WebJobs is published to the web app service in Azure. The details of setting the app and creating the queue are assumed on the reader's part and have already been done. It is also assumed that the reader has a basic understanding of what Azure WebJobs are.

When developing WebJobs, you use Workflow Studio to create the project template and then use Visual Studio to write the code for your particular implementation of the WebJobs.

Anchor
QueueTrigger
QueueTrigger
Queue Trigger

Please follow the steps below to create a WebJob based on a Queue Trigger. The job with a queue trigger is invoked when

  1. 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 RemovedImage Added

  2. Open the properties window for the extension and select AzWebJob_QueueTrigger in the ServiceType property.

  3. Save the Web Job.

  4. Double click the job in the Solution Explorer to load it into Visual Studio.

  5. Open the Appsettings.Json file and update the storage and the below queue values:

    • AzureWebJobsStorage

    :  
    • Connection string of the AzureWebJobsStorage.

    • QueueName

    :
    • Name of the queue which you have already created in your Azure Queue Storage

      Image Modified


      The

    MyWebJobs
    • MyWebJob.cs file has a default method

    ProcessQueueMessageAsync which invokes whenever
    • named ProcessQueueMessageAsync() that is invoked each time a message is received in the queue. By default, it has the code to log a test message.

    Image Removed
    • Image Added

  6. Click on build or follow the instructions in 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 the ..\EmpowerID\WFS\_microservices folder. Look for the zip with the name of the WebJob you created.

  7. Open the Azure portal and navigate to the App Service.

  8. Update Do the following to update the Queue Name in the Application Settings for the App.:

    1. Click on Configuration Menu.

    2. 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 set in Appsettings.json on in step #5 above.

  9. Click on the WebJobs menu and then the Add ➕ button.

  10. Provide the necessary details for the Job and Click on the then click 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
    • #6.

    • Type

    :
    • Select

    job type is ‘
    • Triggered.


    • Image Modified

  11. After seeing the success message of saving the job, click on the Run button to test it.

  12. Now navigate Navigate to the Queue you created and , add some text to the Message Text. Click field and then click the Ok button to save the message.

  13. Open the Job in the browser & and 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
TimerTrigger
TimerTrigger
Timer Trigger

  1. Right-click on the package folder you want to create the Web Job. Click on New Extension or Library → Azure Services .Net 6.0

  2. Open the properties window, and select AzWebJob_QueueTrigger in the ServiceType property.

  3. Save the Web Job.

  4. Double click the job in the Solution Explorer to load it into Visual Studio.

  5. Open the Appsettings.Json file and update the storage setting values. Please ignore the QueueName settings that were required on another WebJobs.

    • AzureWebJobsStorage: Connection string of the AzureWebJobsStorage.

      Image Modified


      The

    MyWebJobs
    • MyWebJob.cs file has a default method

    Run which invokes based on
    • named Run() that is invoked base on the value of the cron expression passed

    on the
    • as arguments. By default,

    it has
    • the method contains code to log a text message every five

    mins
    • minutes. You can change the default cron expression 0 */5 * * * * to 0 */1 * * * * to trigger it every minute if desired.

    Image Removed
    • Image Added

  6. Click on build or follow the instructions in 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 the ..\EmpowerID\WFS\_microservices folder. Look for the zip with the name of the WebJob you created.

  7. Open the Azure portal and navigate to the App Service you want to create the WebJob.

  8. Click on the WebJobs menu and then the Add ➕ button.

  9. 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
    • #6.

    • Type: Select job type is ‘Triggered.’

      Image Modified

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

  11. Now navigate to Job Logs to find if the job ran successfully. You can see the information logged from the WebJob.


Anchor
BlobTrigger
BlobTrigger
Blob Trigger

  1. Right-click on the package folder you want to create the Web Job. Click on New Extension or Library → Azure Services .Net 6.0

  2. Open the properties Properties window , and select set the ServiceType property to AzWebJob_BlobTrigger in the ServiceType property.

  3. Save the Web Job.

  4. Double click the job in the Solution Explorer to load it into Visual Studio.

  5. Open the Appsettings.Json file and update the storage AzureWebJobsStorage and queue values BlobContainerValues:

    • AzureWebJobsStorage: Connection string of the AzureWebJobsStorage.

    • BlobContainerName: Name of the queue you have already created in your Azure Queue Storage.

      Image Modified


      The MyWebJobs.cs file has a default method

    , BlobTrigger, which invokes whenever any
    • named BlobTrigger() that is invoked each time a file is uploaded into a blob container. It

    has
    • contains the code to log a text message whenever a file is uploaded to the

    Blob
    • blob by default.

      Image Modified

  6. Click on build or follow the instructions in 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 the ..\EmpowerID\WFS\_microservices folder. Look for the zip with the name of the WebJob you created.

  7. Open the Azure portal and navigate to the App Service you want to create the WebJob.

  8. Click on the WebJobs menu and then the Add ➕ button.

  9. 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
    • #6.

    • Type: Select job type is ‘Triggered.’

      Image Modified

  10. Once the job is added successfully, Click on the ‘Run’ button to run the job.

  11. Navigate to your blob container and upload a file to test if the WebJob is working fine. Click on the Upload button and select the file to upload.


  12. Now navigate to Job Logs to find if the job ran successfully. You can see the information logged from the WebJob.

Anchor
Continuous
Continuous
Continuous

  1. Right-click on the package folder you want to create the Web Job. Click on New Extension or Library → Azure Services .Net 6.0

  2. Open the properties window, and select AzWebJob_Continuous in the ServiceType property.

  3. Save the Web Job.

  4. Double click the job in the Solution Explorer to load it into Visual Studio.

  5. Open the Appsettings.Json file and update the storage connection string values.

    • AzureWebJobsStorage: Connection string of the AzureWebJobsStorage.

      Image Modified


      The MyWebJobs.cs file has a default method named Run() that runs continuously as a background job after the application

    is started
    • starts.

    Image Removed
    • Image Added

  6. Click on build or follow the instructions in 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 the ..\EmpowerID\WFS\_microservices folder. Look for the zip with the name of the WebJob you created.

  7. Open the Azure portal and navigate to the App Service you want to create the WebJob.

  8. Click on the WebJobs menu and then the Add ➕ button.

  9. 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
    • #6.

    • Type: Select job type is ‘Continuous.’

      Image Modified

  10. You can see that the job is started and is running.

  11. Now navigate to Job Logs to find if the job ran successfully. You can see the output logged for the WebJob that is running continuously.

Div
stylefloat:left; position:fixed;
idarticleNav

IN THIS ARTICLE

Table of Contents
maxLevel4
minLevel2
stylenone
printablefalse

Insert excerpt
IL:External Stylesheet
IL:External Stylesheet
nopaneltrue