Microsoft.Insights/scheduledQueryRules: Include Email Subject & Email body

Thangavel Daniel Tamilarasan 271 Reputation points
2021-07-21T14:46:53.97+00:00

I have the following template , how to add email subject and email body property in this ?

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"type": "string",
"metadata": {
"description": "Name of the alert"
}
},
"location": {
"type": "string",
"metadata": {
"description": "description"
}
},
"alertDescription": {
"type": "string",
"defaultValue": "This is a metric alert",
"metadata": {
"description": "Description of alert"
}
},
"alertSeverity": {
"type": "int",
"defaultValue": 3,
"allowedValues": [
0,
1,
2,
3,
4
],
"metadata": {
"description": "Severity of alert {0,1,2,3,4}"
}
},
"isEnabled": {
"type": "bool",
"defaultValue": true,
"metadata": {
"description": "Specifies whether the alert is enabled"
}
},
"resourceId": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Resource ID of the resource emitting the metric that will be used for the comparison."
}
},
"criterion": {
"type": "object",
"metadata": {
"description": "Criterion includes metric name, dimension values, threshold and an operator."
}
},
"windowSize": {
"type": "string",
"defaultValue": "PT5M",
"allowedValues": [
"PT5M",
"PT15M",
"PT30M",
"PT1H"
],
"metadata": {
"description": "Period of time used to monitor alert activity based on the threshold. Must be between five minutes and one hour. ISO 8601 duration format."
}
},
"evaluationFrequency": {
"type": "string",
"defaultValue": "PT5M",
"allowedValues": [
"PT5M",
"PT15M",
"PT30M",
"PT1H"
],
"metadata": {
"description": "how often the metric alert is evaluated represented in ISO 8601 duration format"
}
},
"actionGroupId": {
"type": "array",
"defaultValue": {},
"metadata": {
"description": "The ID of the action group that is triggered when the alert is activated or deactivated"
}
}
},
"variables": {
"criteria": "[array(parameters('criterion'))]"
},
"resources": [
{
"name": "[parameters('alertName')]",
"type": "Microsoft.Insights/scheduledQueryRules",
"apiVersion": "2020-05-01-preview",
"tags": {},
"location": "[parameters('location')]",
"properties": {
"description": "[parameters('alertDescription')]",
"displayName": "string",
"severity": "[parameters('alertSeverity')]",
"enabled": "[parameters('isEnabled')]",
"scopes": [
"[parameters('resourceId')]"
],
"evaluationFrequency": "[parameters('evaluationFrequency')]",
"windowSize": "[parameters('windowSize')]",
"overrideQueryTimeRange": "string",
"targetResourceTypes": [
"string"
],
"criteria": {
"allOf": [
{
"query": "string",
"timeAggregation": "string",
"metricMeasureColumn": "string",
"resourceIdColumn": "string",
"dimensions": [
{
"name": "string",
"operator": "string",
"values": [
"string"
]
}
],
"operator": "string",
"threshold": "number",
"failingPeriods": {
"numberOfEvaluationPeriods": "integer",
"minFailingPeriodsToAlert": "integer"
}
}
]
},
"muteActionsDuration": "string",
"actions": "[parameters('actionGroupId')]"
}
}
]
}

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,661 questions
0 comments No comments
{count} votes

Accepted answer
  1. Stanislav Zhelyazkov 28,596 Reputation points MVP Volunteer Moderator
    2021-07-23T08:46:00.22+00:00

    Hi,
    Adding e-mail body was never allowed on this API. To be precise there are two versions of this API 2020-05-01-preview and 2018-04-16. Version 2020-05-01-preview represents Log Alert v2 and 2018-04-16 represents Log Alert v1. The APIs although similar they have differences when you create the resource and underneath there are also differences like for example the common alert schema is different. 2018-04-16 had option to override the e-mail subject but that is no longer available in 2020-05-01-preview. Under actions array next to actionGroupId you can add webHookProperties property of type object but where you can add additional static values, but I think those will appear only in webhook payload for action group and not in the e-mail. The workaround to achieve such capability is to send the alert to another automation system (for example logic app) and that one to process the data and send modified e-mail.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.