1

I'm setting up an Azure Alert Rule for a Webtest with Terraform and ARM template. Works fine.

Some of the URLs that I need to check might return "error" (http status code >= 400). When I manually modify or setup the alert, I'd disable "HTTP response" in "Success criteria".

How would I do that in an ARM template? I exported two tests in portal and diff'd them. There's no difference. See https://gist.github.com/alexs77/fc61992f84cf2d3ca80bda54cb2717cb for details.

According to Microsoft.Insights webtests 2018-05-01-preview I would have expected, that setting IgnoreHttpsStatusCode would do just that. But no matter if I set it to true or false, the created web test has "HTTP response" enabled.

Well?!?

How do you create a web test with HTTP resonse disabled?

http response section in webtest configuration

Alexander Skwar
  • 875
  • 1
  • 9
  • 20
  • Hello @alexanderSkwar, if you don't provide parameter `testhttpcode` and `expectedhttpstatuscode` . it won't be set .. as if you would have observed when you pass httpstatuscode 404 , it enables http response and selects response code equals and set it to 404 – Ansuman Bal Dec 03 '21 at 08:45
  • let me try it out and get back here – Ansuman Bal Dec 03 '21 at 08:45
  • If the answer was helpful, Please [Accept it as an Answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work), so that others who encounter the same issue can find this solution and fix their problem. – Ansuman Bal Dec 27 '21 at 05:39

2 Answers2

0

As mentioned in comments , I tested using the same criteria by not providing httpstatuscode in ExpectedHttpStatusCode and setting it to null . I also set the IgnoreHttpsStatusCode as true just to be on safer side.

"ValidationRules": {
            "ExpectedHttpStatusCode": null,
            "IgnoreHttpsStatusCode": true,
            "ContentValidation": null,
            "SSLCheck": true,
            "SSLCertRemainingLifetimeCheck": "[parameters('certRemainingLifetimeCheck')]"
          }

But the above only sets the HTTP response: as null . It doesn't disable the HTTP response. Even if you are not providing ExpectedHttpStatusCode and IgnoreHttpsStatusCode , then also it enables Http Response and sets it to null .

      "ValidationRules": {
        "ContentValidation": null,
        "SSLCheck": true,
        "SSLCertRemainingLifetimeCheck": "[parameters('certRemainingLifetimeCheck')]"
      }

Setting some HTTP code in the response and adding the IgnoreHttpsStatusCode as true will ignore the same http code that you have provided in the test runs as mentioned in the Microsoft Document you have referred to.

enter image description here

enter image description here

Final conclusion will be it is not possible to disable the HTTP response in success criteria using ARM Template but it can be set to Null even if its enabled.

Ansuman Bal
  • 9,705
  • 2
  • 10
  • 27
0

In case someone else comes across this. There's apparently a typo in the spec.

It should be

"ValidationRules": {
  "ExpectedHttpStatusCode": 0,
  "IgnoreHttpStatusCode": true,
  "SSLCheck": true,
  "SSLCertRemainingLifetimeCheck": 30
}

Thanks to this MS Learn forum post

Eonasdan
  • 7,563
  • 8
  • 55
  • 82