0
# Action Groups and Notifications
1
2
Action groups define a collection of notification preferences and automated actions that are triggered when Azure Monitor alerts are fired. They support multiple notification channels including email, SMS, webhooks, Azure Functions, Logic Apps, and integration with ITSM systems.
3
4
## Capabilities
5
6
### Action Group Management
7
8
Create, update, delete, and retrieve action groups with comprehensive notification configurations.
9
10
```python { .api }
11
def create_or_update(resource_group_name: str, action_group_name: str, action_group: ActionGroupResource, **kwargs: Any) -> ActionGroupResource:
12
"""
13
Create a new action group or update an existing one.
14
15
Parameters:
16
- resource_group_name: str - Name of the resource group
17
- action_group_name: str - Name of the action group
18
- action_group: ActionGroupResource - Action group configuration
19
20
Returns:
21
ActionGroupResource - The created or updated action group
22
"""
23
24
def get(resource_group_name: str, action_group_name: str, **kwargs: Any) -> ActionGroupResource:
25
"""
26
Get an action group by name.
27
28
Parameters:
29
- resource_group_name: str - Name of the resource group
30
- action_group_name: str - Name of the action group
31
32
Returns:
33
ActionGroupResource - The action group details
34
"""
35
36
def delete(resource_group_name: str, action_group_name: str, **kwargs: Any) -> None:
37
"""
38
Delete an action group.
39
40
Parameters:
41
- resource_group_name: str - Name of the resource group
42
- action_group_name: str - Name of the action group
43
"""
44
45
def update(resource_group_name: str, action_group_name: str, action_group_patch: ActionGroupPatchBody, **kwargs: Any) -> ActionGroupResource:
46
"""
47
Update an existing action group's tags and properties.
48
49
Parameters:
50
- resource_group_name: str - Name of the resource group
51
- action_group_name: str - Name of the action group
52
- action_group_patch: ActionGroupPatchBody - Properties to update
53
54
Returns:
55
ActionGroupResource - The updated action group
56
"""
57
```
58
59
### Action Group Listing
60
61
List action groups within subscriptions and resource groups with pagination support.
62
63
```python { .api }
64
def list_by_subscription_id(**kwargs: Any) -> ItemPaged[ActionGroupResource]:
65
"""
66
Get a list of all action groups in a subscription.
67
68
Returns:
69
ItemPaged[ActionGroupResource] - Paginated list of action groups
70
"""
71
72
def list_by_resource_group(resource_group_name: str, **kwargs: Any) -> ItemPaged[ActionGroupResource]:
73
"""
74
Get a list of all action groups in a resource group.
75
76
Parameters:
77
- resource_group_name: str - Name of the resource group
78
79
Returns:
80
ItemPaged[ActionGroupResource] - Paginated list of action groups
81
"""
82
```
83
84
### Receiver Management
85
86
Enable and disable specific receivers within action groups, supporting email and SMS receivers.
87
88
```python { .api }
89
def enable_receiver(resource_group_name: str, action_group_name: str, enable_request: EnableRequest, **kwargs: Any) -> None:
90
"""
91
Enable a receiver in an action group (Email or SMS receivers only).
92
93
Parameters:
94
- resource_group_name: str - Name of the resource group
95
- action_group_name: str - Name of the action group
96
- enable_request: EnableRequest - Request to enable receiver
97
"""
98
```
99
100
### Test Notifications
101
102
Send test notifications to validate action group configurations and retrieve test results.
103
104
```python { .api }
105
def begin_create_notifications_at_action_group_resource_level(resource_group_name: str, action_group_name: str, notification_request: NotificationRequestBody, **kwargs: Any) -> LROPoller[TestNotificationDetailsResponse]:
106
"""
107
Send test notifications to a set of provided receivers.
108
109
Parameters:
110
- resource_group_name: str - Name of the resource group
111
- action_group_name: str - Name of the action group
112
- notification_request: NotificationRequestBody - Test notification configuration
113
114
Returns:
115
LROPoller[TestNotificationDetailsResponse] - Long-running operation poller
116
"""
117
118
def get_test_notifications_at_action_group_resource_level(resource_group_name: str, action_group_name: str, notification_id: str, **kwargs: Any) -> TestNotificationDetailsResponse:
119
"""
120
Get the test notifications by the notification id.
121
122
Parameters:
123
- resource_group_name: str - Name of the resource group
124
- action_group_name: str - Name of the action group
125
- notification_id: str - Notification identifier
126
127
Returns:
128
TestNotificationDetailsResponse - Test notification results
129
"""
130
```
131
132
## Usage Examples
133
134
### Creating an Action Group with Multiple Receivers
135
136
```python
137
from azure.mgmt.monitor.models import (
138
ActionGroupResource, EmailReceiver, SmsReceiver,
139
WebhookReceiver, ReceiverStatus
140
)
141
142
# Define receivers
143
email_receivers = [
144
EmailReceiver(
145
name="admin-email",
146
email_address="admin@example.com",
147
use_common_alert_schema=True
148
)
149
]
150
151
sms_receivers = [
152
SmsReceiver(
153
name="admin-sms",
154
country_code="1",
155
phone_number="5551234567"
156
)
157
]
158
159
webhook_receivers = [
160
WebhookReceiver(
161
name="webhook-notification",
162
service_uri="https://example.com/webhook",
163
use_common_alert_schema=True
164
)
165
]
166
167
# Create action group
168
action_group = ActionGroupResource(
169
location="global",
170
group_short_name="AdminAlerts",
171
enabled=True,
172
email_receivers=email_receivers,
173
sms_receivers=sms_receivers,
174
webhook_receivers=webhook_receivers
175
)
176
177
# Create the action group
178
result = client.action_groups.create_or_update(
179
resource_group_name="monitoring-rg",
180
action_group_name="admin-action-group",
181
action_group=action_group
182
)
183
```
184
185
### Testing Action Group Notifications
186
187
```python
188
from azure.mgmt.monitor.models import NotificationRequestBody
189
190
# Prepare test notification request
191
test_request = NotificationRequestBody(
192
alert_type="servicehealth",
193
email_receivers=["admin@example.com"],
194
sms_receivers=[{"country_code": "1", "phone_number": "5551234567"}]
195
)
196
197
# Send test notifications
198
test_operation = client.action_groups.begin_create_notifications_at_action_group_resource_level(
199
resource_group_name="monitoring-rg",
200
action_group_name="admin-action-group",
201
notification_request=test_request
202
)
203
204
# Wait for completion and get results
205
test_result = test_operation.result()
206
print(f"Test notification status: {test_result.state}")
207
```
208
209
## Types
210
211
```python { .api }
212
class ActionGroupResource:
213
"""Action group resource definition."""
214
location: str # Resource location (typically "global")
215
group_short_name: str # Short name for SMS notifications (max 12 chars)
216
enabled: bool # Whether the action group is enabled
217
email_receivers: Optional[List[EmailReceiver]] # Email notification receivers
218
sms_receivers: Optional[List[SmsReceiver]] # SMS notification receivers
219
webhook_receivers: Optional[List[WebhookReceiver]] # Webhook receivers
220
itsm_receivers: Optional[List[ItsmReceiver]] # ITSM system receivers
221
azure_app_push_receivers: Optional[List[AzureAppPushReceiver]] # Azure app push receivers
222
automation_runbook_receivers: Optional[List[AutomationRunbookReceiver]] # Automation runbook receivers
223
voice_receivers: Optional[List[VoiceReceiver]] # Voice call receivers
224
logic_app_receivers: Optional[List[LogicAppReceiver]] # Logic App receivers
225
azure_function_receivers: Optional[List[AzureFunctionReceiver]] # Azure Function receivers
226
arm_role_receivers: Optional[List[ArmRoleReceiver]] # ARM role-based receivers
227
event_hub_receivers: Optional[List[EventHubReceiver]] # Event Hub receivers
228
229
class EmailReceiver:
230
"""Email notification receiver."""
231
name: str # Receiver name
232
email_address: str # Email address
233
use_common_alert_schema: Optional[bool] # Use common alert schema format
234
status: Optional[ReceiverStatus] # Receiver status
235
236
class SmsReceiver:
237
"""SMS notification receiver."""
238
name: str # Receiver name
239
country_code: str # Country code (e.g., "1" for US)
240
phone_number: str # Phone number
241
status: Optional[ReceiverStatus] # Receiver status
242
243
class WebhookReceiver:
244
"""Webhook notification receiver."""
245
name: str # Receiver name
246
service_uri: str # Webhook URL
247
use_common_alert_schema: Optional[bool] # Use common alert schema format
248
use_aad_auth: Optional[bool] # Use Azure AD authentication
249
object_id: Optional[str] # Azure AD object ID for authentication
250
identifier_uri: Optional[str] # Azure AD identifier URI
251
tenant_id: Optional[str] # Azure AD tenant ID
252
253
class ActionGroupPatchBody:
254
"""Action group patch request body."""
255
tags: Optional[Dict[str, str]] # Resource tags
256
enabled: Optional[bool] # Whether action group is enabled
257
258
class EnableRequest:
259
"""Request to enable a receiver."""
260
receiver_name: str # Name of receiver to enable
261
262
class NotificationRequestBody:
263
"""Test notification request body."""
264
alert_type: str # Type of alert (e.g., "servicehealth", "metricAlert")
265
email_receivers: Optional[List[str]] # Email addresses for testing
266
sms_receivers: Optional[List[Dict[str, str]]] # SMS receivers for testing
267
webhook_receivers: Optional[List[Dict[str, str]]] # Webhook receivers for testing
268
269
class TestNotificationDetailsResponse:
270
"""Test notification results."""
271
notification_id: Optional[str] # Notification identifier
272
state: Optional[str] # Notification state
273
completed_time: Optional[str] # Completion timestamp
274
created_time: Optional[str] # Creation timestamp
275
action_details: Optional[List[ActionDetail]] # Detailed results per receiver
276
277
ReceiverStatus = Union["Enabled", "Disabled", "NotSpecified"] # Receiver status values
278
```