You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过ARM模板创建禁用HTTP响应校验的Azure标准Web测试?

解决方案

核心原因

你之前参考的IgnoreHttpsStatusCode参数作用是忽略HTTPS证书校验错误,和你要调整的HTTP响应状态码校验是完全独立的两个配置,这就是该参数修改后不生效的根本原因。
同时你在门户导出的两份ARM模板没有差异,是因为门户导出逻辑不会提取WebTest内嵌XML配置里的规则开关差异,需要手动修改内嵌XML内容实现需求。

ARM模板配置方法

你需要在Microsoft.Insights/webtests资源的properties.Configuration.WebTest字段对应的XML配置中,找到HTTP响应状态码校验的规则节点,将其Enabled属性改为false即可,参考配置片段如下:

{
  "type": "Microsoft.Insights/webtests",
  "apiVersion": "2018-05-01-preview",
  "name": "[parameters('webTestName')]",
  "location": "[parameters('location')]",
  "properties": {
    "SyntheticMonitorId": "[parameters('webTestName')]",
    "Kind": "ping",
    "Enabled": true,
    "Configuration": {
      "WebTest": "<WebTest Name=\"WebTest1\" Id=\"00000000-0000-0000-0000-000000000000\" Enabled=\"True\" CssProjectStructure=\"\" CssIteration=\"\" Timeout=\"30\" WorkItemIds=\"\" xmlns=\"http://microsoft.com/schemas/VisualStudio/TeamTest/2010\" Description=\"\" CredentialUserName=\"\" CredentialPassword=\"\" PreAuthenticate=\"True\" Proxy=\"default\" StopOnError=\"False\" RecordedResultFile=\"\" ResultsLocale=\"\"><Items><Request Method=\"GET\" Guid=\"a5f9f7b3-43a1-4f3a-9b0a-1d2e3f4a5b6c\" Version=\"1.1\" Url=\"[parameters('testUrl')]\" ThinkTime=\"0\" Timeout=\"30\" ParseDependentRequests=\"False\" FollowRedirects=\"True\" RecordResult=\"True\" Cache=\"False\" ResponseTimeGoal=\"0\" Encoding=\"utf-8\" ExpectedHttpStatusCode=\"200\" ExpectedResponseUrl=\"\" ReportingName=\"\" IgnoreHttpStatusCode=\"False\" /></Items><ValidationRules><ValidationRule Classname=\"Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidateResponseStatusCode, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\" Enabled=\"False\" Name=\"ValidateResponseStatusCode\" Description=\"验证响应的 HTTP 状态代码是否在预期范围内。\"><RuleParameters><Parameter Name=\"ExpectedHttpStatusCode\" Value=\"200\" /></RuleParameters></ValidationRule></ValidationRules></WebTest>"
    }
    // 其余配置保持原有逻辑即可
  }
}

Terraform配置方法

如果你使用Terraform的azurerm_application_insights_web_test资源,直接修改web_test参数对应的XML内容,同样将ValidateResponseStatusCode规则的Enabled属性改为false即可。

内容的提问来源于stack exchange,提问作者alexs77

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 05:15:05