How can I configure Azure alerts to monitor WebJob status?

How can I configure Azure alerts to monitor WebJob status?

Ensuring that WebJobs run properly is crucial for maintaining the health and functionality of the Nerdio Manager App Service. Unlike basic monitoring methods, such as regularly checking the /public/health/status page or verifying HTTPS responses, monitoring WebJobs provides deeper insight into whether background tasks are being processed.

In Nerdio Manager, WebJobs have occasionally stopped running after updates, preventing task execution. Proactively monitoring WebJob status helps detect and resolve issues, ensuring jobs are processed as expected.

You can monitor the status of WebJobs using App Insights web tests. For this, create a web test and configure it to access your WebJob's API, and then send you alerts about the job health.

To configure Azure alerts for a web test, complete the following steps:

Step 1: Generate an Authorization Header

The authorization header helps call the WebJob's API and enables the web test to access the WebJob's statuses. The recommended method to generate an authorization header is using Cloud Shell PowerShell.

To generate an authorization header:

  1. In the Azure portal, go to App Services > your app service.

  2. From the left pane, the Settings section, select WebJobs > provision.

  3. From the Properties pane, retrieve the Username and Password values.

  4. In PowerShell, run the following script to generate the authorization header. Ensure you update the script with the Username and Password values you copied in Step 3.

    $user = "`$nmw-app-xxxxxxxxx"

    $pass = “password”

    $authHeader = "Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user, $pass)))

    Write-Output $authHeader

    Once the script run is completed, you receive the following output in the $authHeader parameter:

    Basic

    JHdlXYZabG1pbi............

Next, you need to link the web hook URL to the provision job.

Step 2: Link the Web Hook URL to the Provision WebJob

Once you have generated the authorization header, link the web hook URL directly to the provision job.

To link the web hook URL:

  1. From the WebJobs > provision > Properties pane, copy the URL from the Web Hook field. Manually clear /start from the URL ending.

    Example URL:

    https://nmw-app-abcd.scm.azurewebsites.net/api/continuouswebjobs/provision/start

  2. Navigate to Application Insights > your app service.

  3. On the left pane, the Investigate section, select Availability.

  4. Select Add Standard test, and then define the following test details:

    • In the Basic Information section:

      1. Define the test name.

      2. In URL, enter the Web Hook URL that you copied in Step 1.

        Note: Ensure that the URL doesn't include /start at the end.

      3. Optional. Define the Test frequency and Test locations fields.

    • In the Standard test info section:

      1. In the HTTP Request verb field, ensure GET is defined.

      2. In the Add custom header field, enter Authorization for the header name and $authHeader for the header value.

      3. Select + Add.

    • In the Success criteria section:

      1. Optional. Define the Test Timeout field.

      2. Enable the Content match option.

      3. Ensure the Ignore case option is enabled.

      4. In the Content must contain field, define Running.

    • In the Alerts section, ensure the alerts are enabled.

    Note: Other options can remain as set by default.

The test you created checks whether the provision WebJob is running. Next, you need to enable the test to send email alerts about the job status.

Step 3: Enable the Test Alerts

To start receiving notifications about the provision WebJob status, you need to enable alerts for your test.

To enable alerts for the test:

  1. To the right of your test, select three dots, and then select Open Rules (Alerts) page.

  2. Configure alerts, such as emailing and web hook alerts, using the standard Azure methods.

Was this article helpful?

0 out of 0 found this helpful
Have more questions? Submit a request

Comments (0 comments)

Please sign in to leave a comment.