Resource Group - Generate a Teams Message on CreateΒΆ

This policy will send a notification to a Microsoft Teams channel when a new resource group is created in the subscription. There is a few minute delay between the resource group being created and the notification appearing.

In order to target the correct Teams channel, you will need to insert the custom incoming webhook for the channel. If you do not have a webhook set up, please see Setting up a custom incoming webhook.

We are using an actionable message card to provide a link to the new resource group. Note: linking to portal pages within Azure is not supported by all web browsers.

To run the policy, you must replace <your_webhook_here> with the correct url.

For more information on how the event grid function works please see Azure Functions Hosting

  - name: notify-new-resource-group
    description: |
      Generates a Teams notification when a new resource group is created
    resource: azure.resourcegroup
      type: azure-event-grid
      events: [{
        resourceProvider: Microsoft.Resources/subscriptions/resourceGroups,
        event: write
      - type: webhook
        url: <your_webhook_here>
        batch: false
        body: >
            "@context": ``,
            "@type": `MessageCard`,
            "themeColor": `0072C6`,
            "title": `New Resource Group Created`,
            "text": join('', [`A new resource group has been created in subscription `, account_id, `.\n\nResource Group Name: `,, `\n\nResource Group Location: `, resource.location])
            "potentialAction": [
                "@type": `OpenUri`,
                "name": `Open In Portal`,
                "targets": [
                  "os": `default`,
                  "uri": join('',[``,, `/overview`])