1

I have created 1 web test classic alert through the Azure Portal. Now I want to convert the classic alert to the new alert .I am using the following ARM template for the same.

{
    "name": "TestMetricAlert",
    "type": "Microsoft.Insights/metricAlerts",
    "apiVersion": "2018-03-01",
    "location": "global",
    "tags": {},
    "properties": {
      "description": "Test Metric Description",
      "severity": 2,
      "enabled": true,
      "scopes": [

      ],
      "evaluationFrequency": "PT5M",
      "windowSize": "PT5M",
      "targetResourceType": "Microsoft.Insights/webtests",
      "targetResourceRegion": "eastus",
      "criteria": {
        "additionalProperties": {},
        "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource"
      },
      "dependsOn": [
        "/subscriptions/a85f72bb-4bc4-4a9a-b77b-83db1cc0e1e4/resourceGroups/TestProjectRG/providers/microsoft.insights/webtests/testalert-testappinsights"
      ],
      "autoMitigate": false,
      "actions": [
        {
          "actionGroupId": "/subscriptions/a85f72bb-4bc4-4a9a-b77b-83db1cc0e1e4/resourceGroups/TestProjectRG/providers/microsoft.insights/actionGroups/TestAction"
        }
      ]
    }
  }

But during deployment I am getting the following error.

Template deployment returned the following errors:
11:56:16 - 11:56:15 AM - Resource Microsoft.Insights/metricAlerts 'TestMetricAlert' failed with message '{
11:56:16 - "Code": "BadRequest",
11:56:16 - "Message": "No object created."
11:56:16 - }'

Could someone help me in rectifying what is wrong here or anything needs to be changed in the ARM template.

Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79

1 Answers1

1

Other than trying the Migration tool from the Azure portal, you could also refer to the sample template mentioned in this doc, or even export the template from the Azure portal to check the representation. The following template works for me:

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "metricalerts_test_new_alerts_test_log_analytics_name": {
        "defaultValue": "test-new-alerts-test-log-analytics",
        "type": "String"
    },
    "webtests_test_new_alerts_test_log_analytics_externalid": {
        "defaultValue": "/subscriptions/xxxxx-xxxx-xxx-xxx-xxxxxxxx/resourceGroups/alertrg/providers/microsoft.insights/webtests/test-new-alerts-test-log-analytics",
        "type": "String"
    },
    "components_test_log_analytics_externalid": {
        "defaultValue": "/subscriptions/xxxxx-xxxx-xxx-xxx-xxxxxxxx/resourceGroups/alertrg/providers/microsoft.insights/components/test-log-analytics",
        "type": "String"
    }
},
"variables": {},
"resources": [
    {
        "type": "microsoft.insights/metricalerts",
        "apiVersion": "2018-03-01",
        "name": "[parameters('metricalerts_test_new_alerts_test_log_analytics_name')]",
        "location": "global",
        "tags": {
            "hidden-link:/subscriptions/xxxxx-xxxx-xxx-xxx-xxxxxxxx/resourcegroups/alertrg/providers/microsoft.insights/components/test-log-analytics": "Resource",
            "hidden-link:/subscriptions/xxxxx-xxxx-xxx-xxx-xxxxxxxx/resourcegroups/alertrg/providers/microsoft.insights/webtests/test-new-alerts-test-log-analytics": "Resource"
        },
        "properties": {
            "description": "[concat('Automatically created alert rule for availability test \"', parameters('metricalerts_test_new_alerts_test_log_analytics_name'), '\"')]",
            "severity": 1,
            "enabled": true,
            "scopes": [
                "[parameters('webtests_test_new_alerts_test_log_analytics_externalid')]",
                "[parameters('components_test_log_analytics_externalid')]"
            ],
            "evaluationFrequency": "PT1M",
            "windowSize": "PT5M",
            "criteria": {
                "odata.type": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria"
            },
            "actions": []
        }
    }
]
}

Hope this helps!

Note: The retirement date for classic alerts migration has been extended to August 31st, 2019 from the originally announced date of June 30th, 2019.