Grabbed a sample template for web test from here https://github.com/Azure/azure-quickstart-templates
Issue
I tried deploying my ARM template with a single web test and an associated alert. The deployment of the web test is successful while the deployment fails on the alert step.
Error
[ERROR] target resource id
'/subscriptions/{My_Subscription_Id}/resourceGroups/{My_RG_NAME}/providers/microsoft.insights/webtests/GEN_UNIQUE_8'
is not supported.
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"
}]
}
]
}
}
}
Related
I have a ARM template code to deploy the webapp and slot creating along with app with respective the environment based on the condition. When i try to deploy the resource using the template it only deploys the web app and the slot is not created using the settings on the App. I am new to the ARM stuff could any one please help me out on what i have done wrong with my template.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceGroup": {
"type": "string"
},
"displayNameTag": {
"type": "string"
},
"appInsightName": {
"type": "string"
},
"environment": {
"type": "string"
},
"appType": {
"type": "string"
},
"appServicePlanName": {
"type": "string"
},
"alwaysOn": {
"type": "bool"
},
"currentStack": {
"type": "string"
},
"netFrameworkVersion": {
"type": "string",
"defaultValue": "v4.0"
},
"secondaryApp":{
"type":"string"
}
},
"variables": {
"AustraliaEast": {
"countryCode": "au",
"regionShortCode": "aue",
"regionShortCodePair": "aue",
"omsLocation": "AustraliaEast",
"omsLocationShortCode": "aue",
"PrimaryRegion": true,
"SecondaryRegion": "AustraliaSoutheast",
"regionLocation":"AustraliaEast"
},
"AustraliaSoutheast": {
"countryCode": "au",
"regionShortCode": "aus",
"regionShortCodePair": "aue",
"PrimaryRegion": false,
"regionLocation":"AustraliaSoutheast"
},
"regionSpec": "[variables(resourceGroup().location)]",
"applicationRegion" : "[if(equals(parameters('secondaryApp'),'Yes'),variables('AustraliaSoutheast'),variables('regionspec'))]",
"appName": "[concat('myapp-',parameters('environment'),'-',parameters('appType'),'-',variables('applicationRegion').regionShortcode,'-',parameters('displayNameTag'))]"
},
"resources": [
{
"apiVersion": "2018-11-01",
"name": "[variables('appName')]",
"type": "Microsoft.Web/sites",
"location": "[variables('applicationRegion').regionLocation]",
"tags": {
"displayName": "[parameters('displayNameTag')]",
"environment": "[parameters('environment')]"
},
"dependsOn": [],
"properties": {
"name": "[variables('appName')]",
"mode": "incremental",
"siteConfig": {
"appSettings": [
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(resourceId('Microsoft.Insights/components', parameters('appInsightName')), '2015-05-01').InstrumentationKey]"
},
{
"name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
"value": "[concat('InstrumentationKey=',reference(resourceId('Microsoft.Insights/components', parameters('appInsightName')), '2015-05-01').InstrumentationKey)]"
}
],
"metadata": [
{
"name": "CURRENT_STACK",
"value": "[parameters('currentStack')]"
}
],
"netFrameworkVersion": "[parameters('netFrameworkVersion')]",
"alwaysOn": "[parameters('alwaysOn')]"
},
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]",
"clientAffinityEnabled": true
}
},
{
"condition":"[equals(parameters('secondaryApp'),'Yes')]",
"apiVersion": "2018-11-01",
"type": "Microsoft.Web/sites/slots",
"name": "[concat(variables('appName'), '/', 'Slot-Staging')]",
"location": "[variables('applicationRegion').regionLocation]",
"comments": "This specifies the web app slots.",
"tags": {
"displayName": "WebAppSlots"
},
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]"
},
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('appName'))]"
]
}
],
"outputs": {
"webAppName": {
"type": "string",
"value": "[variables('appName')]"
}
}
}'
Please have a try to add the json code snipped in the ARM template.
"resources": [
{
"apiVersion": "2015-08-01",
"name": "appsettings",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites/Slots', variables('webSiteName'), 'Staging')]"
],
"properties": {
"AppSettingKey1": "Some staging value",
"AppSettingKey2": "My second staging setting",
"AppSettingKey3": "My third staging setting"
}
}
]
Follow this SO for complete reference.
I have defined below a fragment of an ARM template which creates a service bus topic, subscription, and rule/filter. The rule is applied along with the topic and subscription, but the value of the filter is 1=1. Why would the expression not be applied?
{
"apiVersion": "2017-04-01",
"name": "[concat(parameters('serviceBusNamespaceName'), '/TOPIC-NAME')]",
"type": "Microsoft.ServiceBus/namespaces/topics",
"location": "[variables('location')]",
"dependsOn": [
"[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"
],
"properties": {
"path": "TOPIC-NAME",
"duplicateDetectionHistoryTimeWindow": "00:10:00",
"enableBatchedOperations": false,
"enablePartitioning": true,
"enableSubscriptionPartitioning": false,
"filteringMessagesBeforePublishing": false,
"maxSizeInMegabytes": 5120
},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "SUB-NAME",
"type": "subscriptions",
"dependsOn": [
"[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'), '/topics/TOPIC-NAME')]"
],
"properties": {},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "SUB-NAME",
"type": "Rules",
"dependsOn": [
"[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'), '/topics/TOPIC-NAME/subscriptions/SUB-NAME')]"
],
"properties": {
"filter": {
"sqlExpression": "MessageType = 'TYPE-OF-MESSAGE' AND MajorVersion = 1"
},
"action": {
"sqlExpression": "SET sys.Label='TYPE-OF-MESSAGE'"
}
}
}
]
}
]
}
Your subscription rule should be defined as follows:
"resources": [
{
"apiVersion": "2017-04-01",
"name": "SUB-NAME-FILTER",
"type": "Rules",
"dependsOn": [
"[parameters('serviceBusSubscriptionName')]"
],
"properties": {
"filterType": "SqlFilter",
"sqlFilter": {
"sqlExpression": "MessageType = 'TYPE-OF-MESSAGE' AND MajorVersion = 1"
"requiresPreprocessing": "false"
},
"action": {
"sqlExpression": "SET sys.Label='TYPE-OF-MESSAGE'"
}
}
}
]
I create the service bus filter with the following ARM template, it works correctly on my side. More details we could refer to Create a Service Bus namespace with topic, subscription, and rule using an Azure Resource Manager template
I check it with Azure service bus explore
Deploy.json
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serviceBusNamespaceName": {
"type": "string",
"metadata": {
"description": "Name of the Service Bus namespace"
}
},
"serviceBusTopicName": {
"type": "string",
"metadata": {
"description": "Name of the Topic"
}
},
"serviceBusSubscriptionName": {
"type": "string",
"metadata": {
"description": "Name of the Subscription"
}
},
"serviceBusRuleName": {
"type": "string",
"metadata": {
"description": "Name of the Rule"
}
}
},
"variables": {
"location": "[resourceGroup().location]",
"defaultSASKeyName": "RootManageSharedAccessKey",
"authRuleResourceId": "[resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', parameters('serviceBusNamespaceName'), variables('defaultSASKeyName'))]",
"sbVersion": "2017-04-01"
},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "[parameters('serviceBusNamespaceName')]",
"type": "Microsoft.ServiceBus/Namespaces",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard"
},
"properties": {},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "[parameters('serviceBusTopicName')]",
"type": "Topics",
"dependsOn": [
"[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"
],
"properties": {
"defaultMessageTimeToLive": "P10675199DT2H48M5.4775807S",
"maxSizeInMegabytes": "1024",
"requiresDuplicateDetection": "false",
"duplicateDetectionHistoryTimeWindow": "PT10M",
"enableBatchedOperations": "false",
"supportOrdering": "false",
"autoDeleteOnIdle": "P10675199DT2H48M5.4775807S",
"enablePartitioning": "false",
"enableExpress": "false"
},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "[parameters('serviceBusSubscriptionName')]",
"type": "Subscriptions",
"dependsOn": [
"[parameters('serviceBusTopicName')]"
],
"properties": {
"lockDuration": "PT1M",
"requiresSession": "false",
"defaultMessageTimeToLive": "P10675199DT2H48M5.4775807S",
"deadLetteringOnMessageExpiration": "false",
"maxDeliveryCount": "10",
"enableBatchedOperations": "false",
"autoDeleteOnIdle": "P10675199DT2H48M5.4775807S"
},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "[parameters('serviceBusRuleName')]",
"type": "Rules",
"dependsOn": [
"[parameters('serviceBusSubscriptionName')]"
],
"properties": {
"filterType": "SqlFilter",
"sqlFilter": {
"sqlExpression": "MessageType = 'TYPE-OF-MESSAGE' AND MajorVersion = 1",
"requiresPreprocessing": "false"
},
"action": {
"sqlExpression": "SET sys.Label='TYPE-OF-MESSAGE'"
},
"CorrelationFilter": {}
}
}
]
}
]
}
]
}
],
"outputs": {
"NamespaceConnectionString": {
"type": "string",
"value": "[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryConnectionString]"
},
"SharedAccessPolicyPrimaryKey": {
"type": "string",
"value": "[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryKey]"
}
}
}
Paramters.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serviceBusNamespaceName": {
"value": "xxxx-test"
},
"serviceBusTopicName": {
"value": "armtopipc-test"
},
"serviceBusSubscriptionName": {
"value": "armsubscription-test"
},
"serviceBusRuleName": {
"value": "filterRule-test"
}
}
}
I have defined below a fragment of an ARM template which creates a service bus topic, subscription, and rule/filter. The rule is applied along with the topic and subscription, but the value of the filter is 1=1. Why would the expression not be applied?
{
"apiVersion": "2017-04-01",
"name": "[concat(parameters('serviceBusNamespaceName'), '/TOPIC-NAME')]",
"type": "Microsoft.ServiceBus/namespaces/topics",
"location": "[variables('location')]",
"dependsOn": [
"[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"
],
"properties": {
"path": "TOPIC-NAME",
"duplicateDetectionHistoryTimeWindow": "00:10:00",
"enableBatchedOperations": false,
"enablePartitioning": true,
"enableSubscriptionPartitioning": false,
"filteringMessagesBeforePublishing": false,
"maxSizeInMegabytes": 5120
},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "SUB-NAME",
"type": "subscriptions",
"dependsOn": [
"[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'), '/topics/TOPIC-NAME')]"
],
"properties": {},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "SUB-NAME",
"type": "Rules",
"dependsOn": [
"[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'), '/topics/TOPIC-NAME/subscriptions/SUB-NAME')]"
],
"properties": {
"filter": {
"sqlExpression": "MessageType = 'TYPE-OF-MESSAGE' AND MajorVersion = 1"
},
"action": {
"sqlExpression": "SET sys.Label='TYPE-OF-MESSAGE'"
}
}
}
]
}
]
}
Your subscription rule should be defined as follows:
"resources": [
{
"apiVersion": "2017-04-01",
"name": "SUB-NAME-FILTER",
"type": "Rules",
"dependsOn": [
"[parameters('serviceBusSubscriptionName')]"
],
"properties": {
"filterType": "SqlFilter",
"sqlFilter": {
"sqlExpression": "MessageType = 'TYPE-OF-MESSAGE' AND MajorVersion = 1"
"requiresPreprocessing": "false"
},
"action": {
"sqlExpression": "SET sys.Label='TYPE-OF-MESSAGE'"
}
}
}
]
I create the service bus filter with the following ARM template, it works correctly on my side. More details we could refer to Create a Service Bus namespace with topic, subscription, and rule using an Azure Resource Manager template
I check it with Azure service bus explore
Deploy.json
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serviceBusNamespaceName": {
"type": "string",
"metadata": {
"description": "Name of the Service Bus namespace"
}
},
"serviceBusTopicName": {
"type": "string",
"metadata": {
"description": "Name of the Topic"
}
},
"serviceBusSubscriptionName": {
"type": "string",
"metadata": {
"description": "Name of the Subscription"
}
},
"serviceBusRuleName": {
"type": "string",
"metadata": {
"description": "Name of the Rule"
}
}
},
"variables": {
"location": "[resourceGroup().location]",
"defaultSASKeyName": "RootManageSharedAccessKey",
"authRuleResourceId": "[resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', parameters('serviceBusNamespaceName'), variables('defaultSASKeyName'))]",
"sbVersion": "2017-04-01"
},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "[parameters('serviceBusNamespaceName')]",
"type": "Microsoft.ServiceBus/Namespaces",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard"
},
"properties": {},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "[parameters('serviceBusTopicName')]",
"type": "Topics",
"dependsOn": [
"[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"
],
"properties": {
"defaultMessageTimeToLive": "P10675199DT2H48M5.4775807S",
"maxSizeInMegabytes": "1024",
"requiresDuplicateDetection": "false",
"duplicateDetectionHistoryTimeWindow": "PT10M",
"enableBatchedOperations": "false",
"supportOrdering": "false",
"autoDeleteOnIdle": "P10675199DT2H48M5.4775807S",
"enablePartitioning": "false",
"enableExpress": "false"
},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "[parameters('serviceBusSubscriptionName')]",
"type": "Subscriptions",
"dependsOn": [
"[parameters('serviceBusTopicName')]"
],
"properties": {
"lockDuration": "PT1M",
"requiresSession": "false",
"defaultMessageTimeToLive": "P10675199DT2H48M5.4775807S",
"deadLetteringOnMessageExpiration": "false",
"maxDeliveryCount": "10",
"enableBatchedOperations": "false",
"autoDeleteOnIdle": "P10675199DT2H48M5.4775807S"
},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "[parameters('serviceBusRuleName')]",
"type": "Rules",
"dependsOn": [
"[parameters('serviceBusSubscriptionName')]"
],
"properties": {
"filterType": "SqlFilter",
"sqlFilter": {
"sqlExpression": "MessageType = 'TYPE-OF-MESSAGE' AND MajorVersion = 1",
"requiresPreprocessing": "false"
},
"action": {
"sqlExpression": "SET sys.Label='TYPE-OF-MESSAGE'"
},
"CorrelationFilter": {}
}
}
]
}
]
}
]
}
],
"outputs": {
"NamespaceConnectionString": {
"type": "string",
"value": "[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryConnectionString]"
},
"SharedAccessPolicyPrimaryKey": {
"type": "string",
"value": "[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryKey]"
}
}
}
Paramters.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serviceBusNamespaceName": {
"value": "xxxx-test"
},
"serviceBusTopicName": {
"value": "armtopipc-test"
},
"serviceBusSubscriptionName": {
"value": "armsubscription-test"
},
"serviceBusRuleName": {
"value": "filterRule-test"
}
}
}
I am using an ARM template to programmatically create an Application Insights web test and alert rule. The ARM template is based on this article.
Both the web test and the alert rule are created, but the Alerts property of the web test is disabled. The alert rule is listed on the Alert rules blade, however not in the Webtests section, but in the Others section, see picture:
What am I missing in order to get a web test with an enabled alert?
ARM template (the value of WebTest property was removed by SO):
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"webTestName": {
"type": "string"
},
"appName": { "type": "string" }
},
"variables": {
"url": "http://www.google.com",
"testName": "[concat(parameters('webTestName'), '-', toLower(parameters('appName')))]",
"alertRuleName": "[concat(parameters('webTestName'), '-', toLower(parameters('appName')), '-', subscription().subscriptionId)]"
},
"resources": [
{
"name": "[parameters('appName')]",
"type": "Microsoft.Insights/components",
"apiVersion": "2014-04-01",
"kind": "web",
"location": "Central US",
"properties": {
"Application_Type": "web",
"Flow_Type": "Redfield",
"Request_Source": "Unknown",
"Name": "[parameters('appName')]",
"PackageId": null,
"ApplicationId": "[parameters('appName')]"
},
"tags": {
"applicationType": "web"
}
},
{
"name": "[variables('testName')]",
"apiVersion": "2014-04-01",
"type": "microsoft.insights/webtests",
"location": "Central US",
"dependsOn": [
"[resourceId('Microsoft.Insights/components', parameters('appName'))]"
],
"tags": {
"[concat('hidden-link:', resourceId('Microsoft.Insights/components', parameters('appName')))]": "Resource"
},
"properties": {
"Name": "[parameters('webTestName')]",
"Description": "description",
"Enabled": true,
"Frequency": 300,
"Timeout": 120,
"Kind": "ping",
"RetryEnabled": true,
"Locations": [
{
"Id": "us-il-ch1-azr"
},
{
"Id": "emea-se-sto-edge"
},
{
"Id": "emea-nl-ams-azr"
}
],
"Configuration": {
"WebTest": "[concat(' ')]"
},
"SyntheticMonitorId": "[variables('testName')]"
}
},
{
"name": "[variables('alertRuleName')]",
"apiVersion": "2014-04-01",
"type": "Microsoft.Insights/alertrules",
"location": "East US",
"dependsOn": [
"[resourceId('Microsoft.Insights/webtests', variables('testName'))]"
],
"tags": {
"[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('appName')))]": "Resource",
"[concat('hidden-link:', resourceId('microsoft.insights/webtests', variables('testName')))]": "Resource"
},
"properties": {
"name": "[variables('alertRuleName')]",
"description": "Alert for availability test",
"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', variables('testName'))]",
"metricName": "GSMT_AvRaW"
},
"windowSize": "PT5M",
"failedLocationCount": 2
},
"actions": [
{
"$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleEmailAction, Microsoft.WindowsAzure.Management.Mon.Client",
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners": true,
"customEmails": []
}
]
}
}
]
}
It turned out the value of resourceUri is case-sensitive. Solution:
"variables": {
...
"testName": "[toLower(concat(parameters('webTestName'), '-', toLower(parameters('appName'))))]",
"alertRuleName": "[toLower(concat(parameters('webTestName'), '-', toLower(parameters('appName')), '-', subscription().subscriptionId))]"
},
I have a Azure Resource Manager Template that is part of a set of nested templates. It creates a App Insights component, an alert rule against the website for forbidden requests, a multistep web test, and an alert rule against the web test. All the resources except the alert rule against the web test deploy successfully. I can go into the portal and create the alert against the test without issue after the deployment fails.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"company": {
"type": "string"
},
"region": {
"type": "string"
},
"retailerAPIKey": {
"type": "string"
},
"deviceID": {
"type": "string"
},
"lumicastVersion": {
"type": "string"
}
},
"variables": {
"frameworkWebSite": "[concat(parameters('company'),'-BLS-FRAMEWORK-',parameters('region'))]"
},
"resources": [
{
"name": "[concat('ForbiddenRequests ', variables('frameworkWebSite'))]",
"type": "Microsoft.Insights/alertrules",
"location": "[parameters('region')]",
"apiVersion": "2014-04-01",
"tags": {
"displayName": "ForbiddenRequests frameworkWebSite"
},
"properties": {
"name": "[concat('ForbiddenRequests ', variables('frameworkWebSite'))]",
"description": "[concat(variables('frameworkWebSite'), ' has some requests that are forbidden, status code 403.')]",
"isEnabled": false,
"condition": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri": "[concat(resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('frameworkWebSite'))]",
"metricName": "Http403"
},
"operator": "GreaterThan",
"threshold": 0,
"windowSize": "PT5M"
},
"action": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners": true,
"customEmails": [ ]
}
}
},
{
"name": "[variables('frameworkWebSite')]",
"type": "Microsoft.Insights/components",
"location": "Central US",
"apiVersion": "2014-04-01",
"tags": {
"displayName": "Component frameworkWebSite",
"[concat('hidden-link:',resourceGroup().id,'/providers/Microsoft.Web/sites/',variables('frameworkWebSite'))]": "Resource"
},
"properties": {
"applicationId": "[variables('frameworkWebSite')]"
}
},
{
"name": "[concat('siteinit-', variables('frameworkWebSite'))]",
"apiVersion": "2015-05-01",
"type": "Microsoft.Insights/webtests",
"location": "Central US",
"tags": {
"displayName": "WebtestL ABL BSL Init frameworkWebSite",
"[concat('hidden-link:', resourceId('microsoft.insights/components/', variables('frameworkWebSite')))]": "Resource"
},
"dependsOn": [
"[concat('microsoft.insights/components/', variables('frameworkWebSite'))]"
],
"properties": {
"Name": "[concat('GETBytelightInit-',parameters('region'))]",
"Description": "[concat('GETBytelightInit-',parameters('region'),'.webtest')]",
"Enabled": true,
"Frequency": 600,
"Timeout": 120,
"Kind": "multistep",
"Locations": [
{ "Id": "us-il-ch1-azr" },
{ "Id": "us-ca-sjc-azr" },
{ "Id": "us-tx-sn1-azr" }
],
"Configuration": {
"WebTest": "[concat('<workingwebtest goes here>','<ends here>')]"
},
"SyntheticMonitorId": "[concat('siteinit-', variables('frameworkWebSite'))]"
}
},
{
"name": "[concat('siteinit-', variables('frameworkWebSite'), '-alert')]",
"type": "Microsoft.Insights/alertrules",
"apiVersion": "2015-04-01",
"location": "[parameters('region')]",
"tags": {
"displayName": "Alert webtest site Init frameworkWebSite",
"[concat('hidden-link:', resourceId('microsoft.insights/components/', variables('frameworkWebSite')))]": "Resource",
"[concat('hidden-link:', resourceId('microsoft.insights/webtests/', concat('siteinit-', variables('frameworkWebSite'))))]": "Resource"
},
"dependsOn": [
"[concat('microsoft.insights/components/', variables('frameworkWebSite'))]",
"[concat('microsoft.insights/webtests/siteinit-', variables('frameworkWebSite'))]"
],
"properties": {
"name": "[concat('siteinit-', variables('frameworkWebSite'), '-alert')]",
"description": "Alert for site Initialize",
"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/', concat('siteinit-', variables('frameworkWebSite')))]",
"metricName": "GSMT_AvRaW"
},
"windowSize": "PT15M",
"failedLocationCount": 2
},
"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": [ ]
}
}
}
],
"outputs": {
"TestLink": {
"type": "string",
"value": "[resourceId('microsoft.insights/webtests/', concat('siteinit-', variables('frameworkWebSite')))]"
}
}
}
The deployment fails with:
"statusMessage": {
"Code": "ResourceNotFound",
"Message": "Exception of type 'Microsoft.WindowsAzure.Management.Monitoring.MonitoringServiceException' was thrown."
},
This is just the first of many test that will go in this template and each deployment has 2 copies of the site. So manual alert rule creation isn't an option.
I think there is a problem with your resourceUri:
"resourceUri": "[concat(resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('frameworkWebSite'))]",
Give it a try with the resourceId() function:
"resourceUri": "[resourceId(resourceGroup().name, 'Microsoft.Web/sites', variables('frameworkWebSite'))]",
See resourceId() reference here.
Hope this helps.