Use autoscale actions to send email and webhook alert notifications in Azure Monitor

This article shows you how to set up notifications so that you can call specific web URLs or send emails based on autoscale actions in Azure.

Webhooks

Webhooks allow you to send HTTP requests to a specific URL endpoint (callback URL) when a certain event or trigger occurs. Using webhooks, you can automate and streamline processes by enabling the automatic exchange of information between different systems or applications. Use webhooks to trigger custom code, notifications, or other actions to run when an autoscale event occurs.

Email

You can send email to any valid email address when an autoscale event occurs.

Note

Starting April 3, 2024, you won't be able to add any new Co-Administrators for Azure Autoscale Notifications. Azure Classic administrators will be retired on August 31, 2024, and you would not be able to send Azure Autoscale Notifications using Administrators and Co-Administrators after August 31, 2024. For moe information, see Prepare for Co-administrators retirement

Configure Notifications

Use the Azure portal, CLI, PowerShell, or Resource Manager templates to configure notifications.

Set up notifications using the Azure portal.

Select the Notify tab on the autoscale settings page to configure notifications.

Enter a list of email addresses to send notifications to.

Enter a webhook URI to send a notification to a web service. You can also add custom headers to the webhook request. For example, you can add an authentication token in the header, query parameters, or add a custom header to identify the source of the request.

A screenshot showing the notify tab on the autoscale settings page.

Authentication in webhooks

The webhook can authenticate by using token-based authentication, where you save the webhook URI with a token ID as a query parameter. For example, https://mysamplealert/webcallback?tokenid=123-abc456-7890&myparameter2=value123.

Autoscale notification webhook payload schema

When the autoscale notification is generated, the following metadata is included in the webhook payload:

{
    "version": "1.0",
    "status": "Activated",
    "operation": "Scale Out",
    "context": {
        "timestamp": "2023-06-22T07:01:47.8926726Z",
        "id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/rg-001/providers/microsoft.insights/autoscalesettings/AutoscaleSettings-002",
        "name": "AutoscaleSettings-002",
        "details": "Autoscale successfully started scale operation for resource 'ScaleableAppServicePlan' from capacity '1' to capacity '2'",
        "subscriptionId": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
        "resourceGroupName": "rg-001",
        "resourceName": "ScaleableAppServicePlan",
        "resourceType": "microsoft.web/serverfarms",
        "resourceId": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/rg-001/providers/Microsoft.Web/serverfarms/ScaleableAppServicePlan",
        "portalLink": "https://portal.azure.com/#resource/subscriptions/ffffffff-eeee-dddd-cccc-bbbbbbbbbbb0/resourceGroups/rg-001/providers/Microsoft.Web/serverfarms/ScaleableAppServicePlan",
        "resourceRegion": "West Central US",
        "oldCapacity": "1",
        "newCapacity": "2"
    },
    "properties": {
        "key1": "value1",
        "key2": "value2"
    }   
}
Field Mandatory Description
status Yes Status that indicates that an autoscale action was generated.
operation Yes For an increase of instances, it's' "Scale Out." For a decrease in instances, it's' "Scale In."
context Yes Autoscale action context.
timestamp Yes Time stamp when the autoscale action was triggered.
id Yes Resource Manager ID of the autoscale setting.
name Yes Name of the autoscale setting.
details Yes Explanation of the action that the autoscale service took and the change in the instance count.
subscriptionId Yes Subscription ID of the target resource that's being scaled.
resourceGroupName Yes Resource group name of the target resource that's being scaled.
resourceName Yes Name of the target resource that's being scaled.
resourceType Yes Three supported values: "microsoft.classiccompute/domainnames/slots/roles" - Azure Cloud Services roles, "microsoft.compute/virtualmachinescalesets" - Azure Virtual Machine Scale Sets, and "Microsoft.Web/serverfarms" - Web App feature of Azure Monitor.
resourceId Yes Resource Manager ID of the target resource that's being scaled.
portalLink Yes Azure portal link to the summary page of the target resource.
oldCapacity Yes Current (old) instance count when autoscale took a scale action.
newCapacity Yes New instance count to which autoscale scaled the resource.
properties No Optional. Set of <Key, Value> pairs (for example, Dictionary <String, String>). The properties field is optional. In a custom user interface or logic app-based workflow, you can enter keys and values that can be passed by using the payload. An alternate way to pass custom properties back to the outgoing webhook call is to use the webhook URI itself (as query parameters).