This construct provides a type-safe, version-aware implementation of Azure Action Groups using the AZAPI provider framework.
Action Groups serve as the central notification hub for Azure Monitor alerts. They support multiple receiver types including email, SMS, webhook, Azure Functions, Logic Apps, and voice calls.
- Version Management: Automatic resolution to the latest stable API version (2021-09-01)
- Type Safety: Full TypeScript type definitions with JSII compliance
- Multiple Receivers: Support for email, SMS, webhook, Azure Function, Logic App, and voice receivers
- Validation: Schema-driven property validation
- Multi-language: Generated bindings for TypeScript, Python, Java, and C#
This construct is part of the @microsoft/terraform-cdk-constructs package.
npm install @microsoft/terraform-cdk-constructsimport { ActionGroup } from "@microsoft/terraform-cdk-constructs/azure-actiongroup";
import { ResourceGroup } from "@microsoft/terraform-cdk-constructs/azure-resourcegroup";
const resourceGroup = new ResourceGroup(this, "rg", {
name: "my-resource-group",
location: "eastus",
});
const actionGroup = new ActionGroup(this, "ops-team", {
name: "ops-action-group",
groupShortName: "OpsTeam",
resourceGroupId: resourceGroup.id,
emailReceivers: [{
name: "ops-email",
emailAddress: "ops@company.com",
useCommonAlertSchema: true
}],
});const actionGroup = new ActionGroup(this, "critical-alerts", {
name: "critical-action-group",
groupShortName: "Critical",
resourceGroupId: resourceGroup.id,
emailReceivers: [{
name: "oncall-email",
emailAddress: "oncall@company.com",
useCommonAlertSchema: true
}],
smsReceivers: [{
name: "oncall-sms",
countryCode: "1",
phoneNumber: "5551234567"
}],
webhookReceivers: [{
name: "pagerduty-webhook",
serviceUri: "https://events.pagerduty.com/integration/...",
useCommonAlertSchema: true
}],
tags: {
Environment: "Production",
Team: "Operations"
}
});const actionGroup = new ActionGroup(this, "automation-alerts", {
name: "automation-action-group",
groupShortName: "Automation",
resourceGroupId: resourceGroup.id,
azureFunctionReceivers: [{
name: "alert-processor",
functionAppResourceId: "/subscriptions/.../resourceGroups/.../providers/Microsoft.Web/sites/my-function-app",
functionName: "ProcessAlert",
httpTriggerUrl: "https://my-function-app.azurewebsites.net/api/ProcessAlert",
useCommonAlertSchema: true
}],
});const actionGroup = new ActionGroup(this, "workflow-alerts", {
name: "workflow-action-group",
groupShortName: "Workflow",
resourceGroupId: resourceGroup.id,
logicAppReceivers: [{
name: "ticket-creation",
resourceId: "/subscriptions/.../resourceGroups/.../providers/Microsoft.Logic/workflows/create-ticket",
callbackUrl: "https://prod-00.eastus.logic.azure.com:443/workflows/.../triggers/manual/paths/invoke",
useCommonAlertSchema: true
}],
});| Property | Type | Description |
|---|---|---|
name |
string |
The name of the action group |
groupShortName |
string |
Short name for SMS notifications (1-12 alphanumeric characters) |
| Property | Type | Description | Default |
|---|---|---|---|
location |
string |
Azure region | "global" |
enabled |
boolean |
Whether the action group is enabled | true |
emailReceivers |
EmailReceiver[] |
Email notification receivers | [] |
smsReceivers |
SmsReceiver[] |
SMS notification receivers | [] |
webhookReceivers |
WebhookReceiver[] |
Webhook notification receivers | [] |
azureFunctionReceivers |
AzureFunctionReceiver[] |
Azure Function receivers | [] |
logicAppReceivers |
LogicAppReceiver[] |
Logic App receivers | [] |
voiceReceivers |
VoiceReceiver[] |
Voice call receivers | [] |
tags |
Record<string, string> |
Resource tags | {} |
resourceGroupId |
string |
Resource group ID | Required for resource creation |
apiVersion |
string |
Explicit API version | Latest version |
interface EmailReceiver {
name: string; // Receiver name
emailAddress: string; // Email address
useCommonAlertSchema?: boolean; // Use common alert schema (default: false)
}interface SmsReceiver {
name: string; // Receiver name
countryCode: string; // Country code (e.g., "1" for US)
phoneNumber: string; // Phone number
}interface WebhookReceiver {
name: string; // Receiver name
serviceUri: string; // Webhook URL
useCommonAlertSchema?: boolean; // Use common alert schema (default: false)
}interface AzureFunctionReceiver {
name: string; // Receiver name
functionAppResourceId: string; // Function app resource ID
functionName: string; // Function name
httpTriggerUrl: string; // HTTP trigger URL
useCommonAlertSchema?: boolean; // Use common alert schema (default: false)
}interface LogicAppReceiver {
name: string; // Receiver name
resourceId: string; // Logic App resource ID
callbackUrl: string; // Callback URL
useCommonAlertSchema?: boolean; // Use common alert schema (default: false)
}interface VoiceReceiver {
name: string; // Receiver name
countryCode: string; // Country code (e.g., "1" for US)
phoneNumber: string; // Phone number
}The Action Group construct provides the following outputs:
id: The resource ID of the action groupname: The name of the action group
You can reference these in other constructs:
const alert = new MetricAlert(this, "cpu-alert", {
// ... other properties
actions: [{
actionGroupId: actionGroup.id
}]
});- 2021-09-01 (Active, Latest) - Stable API version with full feature support
The construct automatically uses the latest stable version unless explicitly pinned:
const actionGroup = new ActionGroup(this, "my-group", {
name: "my-action-group",
groupShortName: "MyGroup",
apiVersion: "2021-09-01", // Optional: pin to specific version
// ... other properties
});Microsoft recommends using the Common Alert Schema for better integration and consistency. Enable it per receiver:
emailReceivers: [{
name: "ops-email",
emailAddress: "ops@company.com",
useCommonAlertSchema: true // Enable common alert schema
}]Benefits of Common Alert Schema:
- Unified payload format across all alert types
- Easier to build integrations
- Better parsing and processing
- Consistent field names and structure
- Use Short Names Wisely: The
groupShortNameappears in SMS messages (max 12 characters) - Enable Common Alert Schema: Set
useCommonAlertSchema: truefor better integration - Tag Your Resources: Add meaningful tags for organization and cost tracking
- Multiple Receivers: Configure multiple receiver types for redundancy
- Test Receivers: Use the Azure Portal's "Test action group" feature after deployment
See the examples directory for complete working examples:
- Basic action group setup
- Multi-receiver configurations
- Integration with metric alerts
- Integration with activity log alerts
MetricAlert- Metric-based alertingActivityLogAlert- Activity log alerting