用于Azure上的Web测试的ARM在警报规则上失败

时间:2016-08-16 23:28:09

标签: azure azure-resource-manager

从此处https://github.com/Azure/azure-quickstart-templates

获取用于网络测试的示例模板

问题

我尝试使用单个Web测试和相关警报部署我的ARM模板。在警报步骤中部署失败时,Web测试的部署成功。

错误

  

[ERROR]目标资源ID   '/subscriptions/{My_Subscription_Id}/resourceGroups/{My_RG_NAME}/providers/microsoft.insights/webtests/GEN_UNIQUE_8'   不受支持。

azuredeploy.json

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "appName": {
      "type": "string",
      "metadata": {
        "description": "The name of the app insights"
      }
    },
    "tests": {
      "type": "array",
      "metadata": {
        "description": "The list of web tests to run."
      }
    },
    "emails": {
      "type": "array",
      "metadata": {
        "description": "email addresses to send alerts to."
      }
    }
  },
  "variables": {
  },
  "resources": [
    {
      "apiVersion": "2015-05-01",
      "name": "[parameters('appName')]",
      "type": "microsoft.insights/components",
      "location": "Central US",
      "tags": {
        "AppInsightsApp": "MyApp"
      },
      "properties": {
        "Application_Type": "web",
        "Flow_Type": "Redfield",
        "Request_Source": "Unknown",
        "Name": "testapp",
        "ApplicationId": "[parameters('appName')]"
      },
      "kind": "web"
    },
    {
      "name": "[parameters('tests')[0].name]",
      "apiVersion": "2015-05-01",
      "type": "microsoft.insights/webtests",
      "location": "Central US",
      "tags": {
        "[concat('hidden-link:', resourceId('microsoft.insights/components/', parameters('appName')))]": "Resource"
      },
      "dependsOn": [
        "[concat('microsoft.insights/components/', parameters('appName'))]"
      ],
      "properties": {
        "Name": "[parameters('tests')[0].name]",
        "Description": "[parameters('tests')[0].description]",
        "Enabled": true,
        "Frequency": "[parameters('tests')[0].frequency_secs]",
        "Timeout": "[parameters('tests')[0].timeout_secs]",
        "Kind": "ping",
        "Locations": "[parameters('tests')[0].locations]",
        "Configuration": {
          "WebTest": "[concat('<WebTest Name=\"', parameters('tests')[0].name, '\"',  ' Id=\"', parameters('tests')[0].guid ,'\"    Enabled=\"True\" CssProjectStructure=\"\" CssIteration=\"\" Timeout=\"0\" 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=\"a5f10126-e4cd-570d-961c-cea43999a200\" Version=\"1.1\" Url=\"', parameters('tests')[0].url ,'\" ThinkTime=\"0\" Timeout=\"300\" ParseDependentRequests=\"True\" FollowRedirects=\"True\" RecordResult=\"True\" Cache=\"False\" ResponseTimeGoal=\"0\" Encoding=\"utf-8\" ExpectedHttpStatusCode=\"', parameters('tests')[0].expected ,'\" ExpectedResponseUrl=\"\" ReportingName=\"\" IgnoreHttpStatusCode=\"False\" /></Items></WebTest>')]"
        },
        "SyntheticMonitorId": "[parameters('tests')[0].name]"
      }
    },
    {
      "name": "[concat(parameters('tests')[0].name, 'alert')]",
      "type": "Microsoft.Insights/alertRules",
      "apiVersion": "2015-04-01",
      "location": "Central US",
      "tags": {
        "[concat('hidden-link:', resourceId('microsoft.insights/components/', parameters('appName')))]": "Resource",
        "[concat('hidden-link:', resourceId('microsoft.insights/webtests/', parameters('tests')[0].name))]": "Resource"
      },
      "dependsOn": [
        "[concat('microsoft.insights/components/', parameters('appName'))]",
        "[concat('microsoft.insights/webtests/', parameters('tests')[0].name)]"
      ],
      "properties": {
        "name": "[parameters('tests')[0].name]",
        "description": "[parameters('tests')[0].description]",
        "isEnabled": true,
        "condition": {
          "$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.LocationThresholdRuleCondition, Microsoft.WindowsAzure.Management.Mon.Client",
          "odata.type": "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition",
          "dataSource": {
            "$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleMetricDataSource, Microsoft.WindowsAzure.Management.Mon.Client",
            "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
            "resourceUri": "[resourceId('microsoft.insights/webtests/', parameters('tests')[0].name)]",
            "metricName": "GSMT_AvRaW"
          },
          "windowSize": "PT15M",
          "failedLocationCount": "[parameters('tests')[0].failedLocationCount]"
        },
        "action": {
          "$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleEmailAction, Microsoft.WindowsAzure.Management.Mon.Client",
          "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
          "sendToServiceOwners": true,
          "customEmails": "[parameters('emails')]"
        }
      }
    }
  ]
}

azureparams.json

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "appName": {
      "value": "someapp"
    },
    "emails": {
      "value": [
        "mymail@amydomain.com"
      ]
    },
    "tests": {
      "value": [
        {
          "name": "GEN_UNIQUE_8",
          "url": "http://www.microsoft.com",
          "expected": 200,
          "frequency_secs": 300,
          "timeout_secs": 30,
          "failedLocationCount": 1,
          "description": "a description for test1",
          "guid": "cc1c4b95-0a39-48ce-9c7b-fa41f0fc0bee",
          "locations": [{
            "Id": "us-il-ch1-azr"
          }]
        }
      ]
    }
  }
}

0 个答案:

没有答案