@Pradeep Kumar Ramagiri Thanks for your question. I have modified the template with below changes and tested the template in azure portal. Its deployed successfully. Kindly try from your end and let me know if you still face the issue.
- Removed resourceId parameter as we have resourceId() function.
- Also, to retrieve subscription, I have used subscription() fucntion.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"type": "String",
"metadata": {
"description": "The name of the alert rule."
}
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Insights/actionGroups",
"apiVersion": "2018-03-01",
"name": "SubHealth",
"location": "Global",
"properties": {
"groupShortName": "ERC",
"enabled": true,
"emailReceivers": [
{
"name": "CTS-Email",
"emailAddress": "******@gmail.com"
}
]
}
},
{
"type": "Microsoft.Insights/activityLogAlerts",
"apiVersion": "2017-04-01",
"name": "[parameters('alertName')]",
"location": "Global",
"dependsOn": [
"Microsoft.Insights/actionGroups/SubHealth"
],
"properties": {
"enabled": true,
"description": "This is the description of the alert rule.",
"scopes": [
"[subscription().id]"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth"
},
{
"anyOf": [
{
"field": "properties.incidentType",
"equals": "Incident"
},
{
"field": "properties.incidentType",
"equals": "Planned Maintenance"
}
]
},
{
"field": "properties.impactedServices[*].ServiceName",
"containsAny": [
"ExpressRoute \\ ExpressRoute Circuits"
]
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "[resourceId('Microsoft.Insights/actionGroups', 'SubHealth')]",
"webhookProperties": {}
}
]
}
}
}
]
}
Reference document : https://learn.microsoft.com/en-us/azure/service-health/resource-health-alert-arm-template-guide#resource-manager-template-options-for-resource-health-alerts