Do availability tests content match support regex match?

Yashas Manjunath 206 Reputation points
2026-06-24T07:51:48.5666667+00:00

I have an availability test deployed in Azure for my web app, which listens to a health endpoint. The health endpoint returns a response that contains OverallStatus: Healthy, and sometimes, depending on the version of the app deployed, it returns OverallStatus:Healthy (this time without a space between the colon and the word 'Healthy').

When this happens, my availability test starts to fail because the content does not match what I have described. In cases like this, does the availability test support regex expressions that can handle both cases, or is it a strict text match?

User's image

above image is the current setup. Below is what I Ideally want.
Does the standard availability test support regex for the "context must contain" section

User's image

Azure Monitor
Azure Monitor

An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.


Answer accepted by question author

Sina Salam 30,566 Reputation points Volunteer Moderator
2026-06-27T10:43:17.3833333+00:00

Hello Yashas Manjunath,

Welcome to the Microsoft Q&A and thank you for posting your questions here.

I understand that you're asking if availability tests content match support regex match.

The failure is caused by the Content must contain validation using a literal text match, not a regex match. Standard availability tests expose ContentMatch, IgnoreCase, and PassIfTextFound, but there is no documented regex option, whitespace-normalization option, JSONPath selector, or “match either value” setting. Therefore, a regex pattern such as OverallStatus:\s*Healthy is not supported for this field. Therefore, standard availability test content validation does not support regex.

The best resolution is to standardize the health endpoint response so every application version returns one stable success token, then configure the availability test to match that exact value. For example, return:

AvailabilityTestStatus=Healthy

and configure Content must contain with the same exact value:

AvailabilityTestStatus=Healthy

If the endpoint cannot be changed and you must support both spacing formats, then Standard availability test content validation is not the right tool for that logic. In that case, implement a custom availability test where your code performs regex or response normalization, and then sends the result to Application Insights using availability telemetry. Microsoft documents custom availability testing as the valid path when you need to run your own test logic and submit results to Application Insights.

Use the below official Microsoft resources for more reading and implementation steps:

Do not hesitate to let me know if you have any other questions, steps or clarifications.


I hope this is helpful. Please close the thread by upvoting and accepting the answer if any part of it is helpful.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Bharath Y P 10,340 Reputation points Microsoft External Staff Moderator
    2026-06-24T11:15:23.4566667+00:00

    Hello Yashas, we understand that your Standard availability test uses Content must contain and your app sometimes returns overallStatus:Healthy (no space after the colon) while other deployments return overallStatus: Healthy (with a space). When the formatting changes, the content-match condition fails.

    As per the official docs, the Standard availability test "Content match" does NOT support regular expressions. It performs a strict, exact, plain-string match.

    User's image Application Insights availability tests

    As per the above there is no way to express "match OverallStatus:Healthy or OverallStatus: Healthy" (with/without the space) in a single content-match rule. No regex, no wildcards, no alternation.

    Your health endpoint returns two variants depending on the deployed version:

    • OverallStatus: Healthy (with space)
    • OverallStatus:Healthy (no space)

    Because content match is literal, only the variant you typed will pass; the other fails.

    Recommended workarounds:

    Match on a substring common to both variants: Set Content match to just Healthy instead of the full OverallStatus: Healthy. Both responses contain the word Healthy, so both pass.

    If the degraded response like OverallStatus: Unhealthy also contains Healthy and would wrongly pass. If your unhealthy state uses words like Unhealthy/Degraded.

    Normalize the endpoint output: The real root cause is the endpoint emitting two different strings for the same state. Fix it at the source so the health response is deterministic — always emit a stable, unambiguous token, e.g. a JSON field "status":"Healthy" or a fixed string STATUS=HEALTHY. Then content-match that exact token. This removes the version-dependent whitespace difference entirely (ASP.NET Core Health Checks lets you customize the response writer to do this).

    For example: If your using ASP.NET Core app, find where health checks are configured (usually Program.cs or Startup.cs) and replace the default response writer.

    Use a custom TrackAvailability() test for regex/complex logic. For genuine regex or multi-condition validation, drop the built-in content match and run your own probe (Azure Function timer / Automation runbook / TrackAvailability() SDK) that calls the endpoint, applies regex in your own code (e.g. OverallStatus:\s*Healthy), and posts the pass/fail result to Application Insights as an availability result. This is the only supported way to get regex-style matching.

    Monitor .NET and Node.js Applications with Application Insights (Classic API 2.x) - Azure Monitor | Microsoft Learn

    Hope this helps! Please let me know if you have any questions.

    Thank you

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.