Επεξεργασία

Κοινή χρήση μέσω


Create and configure Resource Health alerts

This article shows how to create and configure Azure Resource Health alerts using the Azure portal, Azure PowerShell, Azure Resource Manager (ARM) templates, and Azure CLI.

Resource Health alerts notify you when your Azure resources experience a change in health status, such as becoming unavailable or degraded. These alerts help you stay informed and respond quickly to service issues affecting your workloads.

Create a Resource Health alert rule in the Service Health portal

  1. In the Azure portal, select Service Health.

Screenshot of Service Health option.

  1. Select Resource Health.

Screenshot of Resource Health option.

  1. Select Add resource health alert.

Screenshot of Resource Health create option.

The Create an alert rule wizard opens the Condition tab, with the Scope tab already populated.

Screenshot of Resource Health scope tab.

  1. Follow the steps to create Resource Health alerts, starting from the Condition tab, in the Alert rule wizard.

Screenshot of Resource Health condition tab.

Create a Resource Health alert using PowerShell

Note

We recommend that you use the Azure Az PowerShell module to interact with Azure. To get started, see Install Azure PowerShell. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.

To follow the instructions on this page, you need to set up a few things in advance:

  1. You need to install the Azure PowerShell module.
  2. You need to create or reuse an Action Group configured to notify you.

Instructions for PowerShell

  1. Use PowerShell to sign-in to Azure using your account, and select the subscription you want to use.

    Login-AzAccount
    Select-AzSubscription -Subscription <subscriptionId>
    

    Note

    You can use Get-AzSubscription to list the subscriptions you have access to.

  2. Find and save the full Azure Resource Manager ID for your Action Group.

    (Get-AzActionGroup -ResourceGroupName <resourceGroup> -Name <actionGroup>).Id
    
  3. Create and save an ARM template for Resource Health alerts as resourcehealthalert.json (see details)

  4. Create a new Azure Resource Manager deployment using this template.

    New-AzResourceGroupDeployment -Name ExampleDeployment -ResourceGroupName <resourceGroup> -TemplateFile <path\to\resourcehealthalert.json>
    
  5. You're prompted to type in the Alert Name and Action Group Resource ID you copied earlier:

    Supply values for the following parameters:
    (Type !? for Help.)
    activityLogAlertName: <Alert Name>
    actionGroupResourceId: /subscriptions/<subscriptionId>/resourceGroups/<resourceGroup>/providers/microsoft.insights/actionGroups/<actionGroup>
    
  6. If everything worked successfully, you get a confirmation in PowerShell

    DeploymentName          : ExampleDeployment
    ResourceGroupName       : <resourceGroup>
    ProvisioningState       : Succeeded
    Timestamp               : 11/8/2017 2:32:00 AM
    Mode                    : Incremental
    TemplateLink            :
    Parameters              :
                            Name                     Type       Value
                            ===============          =========  ==========
                            activityLogAlertName     String     <Alert Name>
                            activityLogAlertEnabled  Bool       True
                            actionGroupResourceId    String     /...
    
    Outputs                 :
    DeploymentDebugLogLevel :
    

Note

If you're planning on fully automating this process, you simply need to edit the ARM template to not prompt for the values in Step 5.

Create Resource health alerts using template options

You can use this base template as a starting point for creating Resource Health alerts. This template works as written, and signs you up to receive alerts for all newly activated resource health events across all resources in a subscription.

Note

The Resource Health alert template is a more complex alert template, which should increase the signal to noise ratio for Resource Health alerts as compared to this template.

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "activityLogAlertName": {
      "type": "string",
      "metadata": {
        "description": "Unique name (within the Resource Group) for the Activity log alert."
      }
    },
    "actionGroupResourceId": {
      "type": "string",
      "metadata": {
        "description": "Resource Id for the Action group."
      }
    }
  },
  "resources": [   
    {
      "type": "Microsoft.Insights/activityLogAlerts",
      "apiVersion": "2017-04-01",
      "name": "[parameters('activityLogAlertName')]",      
      "location": "Global",
      "properties": {
        "enabled": true,
        "scopes": [
            "[subscription().id]"
        ],        
        "condition": {
          "allOf": [
            {
              "field": "category",
              "equals": "ResourceHealth"
            },
            {
              "field": "status",
              "equals": "Active"
            }
          ]
        },
        "actions": {
          "actionGroups":
          [
            {
              "actionGroupId": "[parameters('actionGroupResourceId')]"
            }
          ]
        }
      }
    }
  ]
}

However, a broad alert like this one isn't recommended. Learn how we can scope down this alert to focus on the events we care about.

Next steps

Learn more about Resource Health:

Create Service Health Alerts: