1
votes

When creating an Action Group on the Azure Portal, you have the option to create an action on an action group to Email an Azure Resource Manager Role like Owner.

Trying to Automate the action groups per subscription/resource group, I can't find any documentation on how to create such a receiver via Powershell or CLI. There is the standard EmailReceiver and others, but nothing that is specific to the Role of the specific Resource group.

The intention is to create an Action Group that sends an email to everybody in the Owner group. Looking at the templates, it also is blank for all receivers with no indication on actually where it defines the "role" it needs to send to.

Any help will be appreciated.

enter image description here

1

1 Answers

2
votes

If I am correctly understanding you. You could try to create an Email ARM Role by using armRoleReceivers parameter. When you do this, you could set the name value as the same as the name for emailReceivers and a specific roleId in the action group. For example, If you want to set a built-in owner role of this, you should set roleId 8e3af657-a8ff-443c-a75c-2fe8c4bcb635.

Something should be like:

"armRoleReceivers": [
  {
    "name": "string",
    "roleId": "8e3af657-a8ff-443c-a75c-2fe8c4bcb635"
  }
]

You could find microsoft.insights actionGroups template reference, Here is a template working on my side.

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
    "actionGroupName": {
      "type": "string",
      "metadata": {
        "description": "Unique name (within the Resource Group) for the Action group."
      }
    },
    "actionGroupShortName": {
      "type": "string",
      "metadata": {
        "description": "Short name (maximum 12 characters) for the Action group."
      }
    }
  },
    "resources": [
{
  "name": "[parameters('actionGroupName')]",
  "type": "microsoft.insights/actionGroups",
  "apiVersion": "2018-09-01",
  "location": "Global",
  "properties": {
    "groupShortName": "[parameters('actionGroupShortName')]",
    "enabled": true,
    "emailReceivers": [
      {
        "name": "contosoEmail",
        "emailAddress": "[email protected]"
      }
    ],
    "smsReceivers": [
      {
        "name": "contosoSMS",
        "countryCode": "1",
        "phoneNumber": "555555"
      }
    ],
    "armRoleReceivers": [
      {
        "name": "contosoEmail",
        "roleId": "8e3af657-a8ff-443c-a75c-2fe8c4bcb635"
      }
    ]
  }
}
    ]
}

enter image description here