アクショングループ(Azure Monitor)の有効・無効化手順

Azure,Monitor

Azure Monitorのアクショングループの有効・無効化手順です。
Azure Portalだけではなく、Azure PowerShell、Azure CLIやREST APIを使った手順を紹介しています。
アクショングループを無効化した場合の動作についても確認しています。

※Azure PowerShell(Azモジュール)は11.2.0を利用しています。
※Azure CLIは2.54.0を利用しています。
※Azure REST APIはブラウザから実行しています。実行時のAPI Versionは2021-09-01です。

スポンサーリンク

アクショングループの有効・無効化

使用したアクショングループ

事前に作成したアクショングループを利用します。
アクションにはメール通知を設定しています。

    • 使用したアクショングループ名(リソースグループ:test-rg-01)
      • Azure Portal:actiongroup-01
      • Azure PowerShell:actiongroup-02
      • REST API:actiongroup-03
      • Azure CLI:actiongroup-04

アクショングループの作成手順などについてはこちらに纏めています。
併せて見て頂けると有難いです。

Azure Portal

Azure Portalからアクショングループを有効・無効化します。
アクショングループに有効化もしくは無効化ボタンが表示されます。

  • 表示されるボタン
    • アクショングループ有効時:無効化ボタン
    • アクショングループ無効時:有効化ボタン
アクショングループの有効・無効化
アクショングループの概要から有効化、無効化出来ます。
アクショングループが有効の場合には無効化ボタンが、無効の場合には有効化ボタンが表示されます。
【無効化】
【有効化】

Azure PowerShell

Azure PowerShellを利用してアクショングループの有効化および無効化します。
有効化無効化にはUpdate-AzActionGroupではなくNew-AzActionGroupを使用します。

New-AzActionGroup

※Update-AzActionGroupもありますがEnabledパラメータの変更についてはNew-AzActionGroup利用します。
※Azure PowerShell(Azモジュール)は11.2.0を利用しています。11以降ではSet-AzActionGroupが無くなっています。

アクショングループの有効・無効化

アクショングループの情報を取得には、Get-AzActionGroupを利用します。
アクショングループを更新には、New-AzActionGroupを使用します。
New-AzActionGroupのパラメータには、取得したアクショングループの設定内容を指定します。
New-AzActionGroupのEnabledパラメータを利用して有効・無効化します。

  • New-AzActionGroup実行時のEnabledパラメータ設定
    • 無効化:オプション無し
    • 有効化:オプション有り

【無効化】

$resourcegroupname = “test-rg-01″ #リソースグループ名
$actiongroupname = “actiongroup-02" #アクショングループ名

$actiongroup = Get-AzActionGroup -ResourceGroupName $resourcegroupname -name $actiongroupname

New-AzActionGroup -Name $actiongroup.Name `
-ResourceGroupName $actiongroup.ResourceGroupName `
-Location $actiongroup.Location `
-GroupShortName $actiongroup.GroupShortName `
-EmailReceiver $actiongroup.EmailReceiver

【有効化】

$resourcegroupname = “test-rg-01″ #リソースグループ名
$actiongroupname = “actiongroup-02" #アクショングループ名

$actiongroup = Get-AzActionGroup -ResourceGroupName $resourcegroupname -name $actiongroupname

New-AzActionGroup -Name $actiongroup.Name `
-ResourceGroupName $actiongroup.ResourceGroupName `
-Location $actiongroup.Location `
-GroupShortName $actiongroup.GroupShortName `
-EmailReceiver $actiongroup.EmailReceiver `
-Enabled

実行結果からアクショングループの設定を確認します。
“enabled": falseになっている事が確認出来ます。

【実行結果(無効化時)】

ArmRoleReceiver : {}
AutomationRunbookReceiver : {}
AzureAppPushReceiver : {}
AzureFunctionReceiver : {}
EmailReceiver : {{
   “name": “mail-02_-EmailAction-“,
   “emailAddress": “通知先メールアドレス",
   “useCommonAlertSchema": true,
    “status": “Enabled"
   }}
Enabled : False
EventHubReceiver : {}
GroupShortName : ag-02
Id : /subscriptions/サブスクリプションID/resourceGroups/test-rg-01/providers/microsoft.insights/actionGroups/actiongroup-02
ItsmReceiver : {}
Location : Global
LogicAppReceiver : {}
Name : actiongroup-02
ResourceGroupName : test-rg-01
SmsReceiver : {}
Tag : {
}
Type : Microsoft.Insights/ActionGroups
VoiceReceiver : {}
WebhookReceiver : {}

Azure REST API

Azure REST APIを利用してアクショングループの有効化および無効化します。

Action Groups – Create Or Update

※Azure REST APIはブラウザから実行しています。実行時のAPI Versionは2021-09-01です。

アクショングループの有効・無効化

本文内の"enabled"の項目が有効化無効化に対応します。

  • Azure REST API実行時の設定値
    • 無効化:"enabled": false
    • 有効化:"enabled": true

【要求URL例(PUT)】【無効化】

https://management.azure.com/subscriptions/サブスクリプションID/resourceGroups/test-rg-01/providers/Microsoft.Insights/actionGroups/actiongroup-03?api-version=2021-09-01

{
  “location": “Global",
  “tags": {},
  “properties": {
  “groupShortName": “ag-03",
  “enabled": false,
  “emailReceivers": [
  {
    “name": “mail-03",
    “emailAddress": “通知先メールアドレス",
    “useCommonAlertSchema": true
   }
  ]
 }
}

アクショングループの設定を確認します。
“enabled": falseになっている事が確認出来ます。

【要求URL例(GET)】
https://management.azure.com/subscriptions/サブスクリプションID/resourceGroups/test-rg-01/providers/Microsoft.Insights/actionGroups/actiongroup-03?api-version=2021-09-01

 

{
 “id": “/subscriptions/サブスクリプションID/resourceGroups/test-rg-01/providers/microsoft.insights/actionGroups/actiongroup-03",
 “type": “Microsoft.Insights/ActionGroups",
 “name": “actiongroup-03",
 “location": “Global",
 “kind": null,
 “tags": null,
 “properties": {
   “groupShortName": “ag-03",
   “enabled": false,
   “emailReceivers": [
   {
     “name": “mail-03",
     “emailAddress": “送信先メールアドレス",
     “useCommonAlertSchema": true,
     “status": “Enabled"
   }
  ],
  “smsReceivers": [],
  “webhookReceivers": [],
  “eventHubReceivers": [],
  “itsmReceivers": [],
  “azureAppPushReceivers": [],
  “automationRunbookReceivers": [],
  “voiceReceivers": [],
  “logicAppReceivers": [],
  “azureFunctionReceivers": [],
  “armRoleReceivers": []
 }
}

Azure CLI

Azure CLIを利用してアクショングループの有効化および無効化します。
アクショングループの有効・無効化にはaz monitor action-group updateを使用します。

※Azure CLIは2.54.0を利用しています。

アクショングループの有効・無効化

az monitor action-group updateのsetパラメータを利用します。

  • az monitor action-group updateのsetパラメータ設定
    • 無効化:–set enabled=false
    • 有効化:–set enabled=true

【無効化】

$resourcegroupname = “test-rg-01″ #リソースグループ名
$actiongroupname = “actiongroup-04" #アクショングループ名

az monitor action-group update –resource-group $resourcegroupname –name $actiongroupname –set enabled=false

実行結果からアクショングループの設定を確認します。
“enabled": falseになっている事が確認出来ます。

【実行結果】

{
“armRoleReceivers": [],
“automationRunbookReceivers": [],
“azureAppPushReceivers": [],
“azureFunctionReceivers": [],
“emailReceivers": [
{
“emailAddress": “通知先メールアドレス",
“name": “mail-04",
“status": “Enabled",
“useCommonAlertSchema": true
}
],
“enabled": false,
“eventHubReceivers": [],
“groupShortName": “ag-04",
“id": “/subscriptions/サブスクリプションID/resourceGroups/test-rg-01/providers/microsoft.insights/actionGroups/actiongroup-04",
“itsmReceivers": [],
“location": “Global",
“logicAppReceivers": [],
“name": “actiongroup-04",
“resourceGroup": “test-rg-01",
“smsReceivers": [],
“type": “Microsoft.Insights/ActionGroups",
“voiceReceivers": [],
“webhookReceivers": []
}

—広告—

アクショングループ無効化時にアラートが発生した場合

アクショングループ無効化時にアラートが発生した場合は以下の動作になります。

    • アクショングループの状態(有効、無効)に関わらずトリガーされる
    • 無効化されたアクショングループの場合はトリガーされても実行されない
    • 有効、無効のアクショングループが混在する場合は有効なアクショングループのみ実行される
アクショングループの動作確認

1つのメトリックアラートルールに2つのアクショングループを割り当てて動作を確認します。
actiongroup-01は有効、02は無効にしています。

アラートを発生させて確認します。
アクショングループの有効無効状態に関わらずトリガーされています。
トリガーされますが無効化アクショングループは実行されません。
無効化されたアクショングループに設定したメールアドレスへはアラート通知メールは届きません。
有効状態にアクショングループのメールアドレスへはアラート通知メールが届きます。

最後に

Azure Portal、Azure PowerShell、Azure CLI、REST APIを使ったアクショングループの無効化手順をまとめてみました。
アラート自体の発生には影響なく特定の通知だけを止めるといった事が出来るので便利かとは思います。
アラート処理ルールと組み合わせて使うとAzure Monitorの非監視対応が柔軟に出来そうです。

    • アラート処理ルール:主にリソース単位でアラートを停止させる場合に利用
    • アクショングループを停止:アクショングループ自体を停止する場合に利用

※アラート処理ルールには非監視以外の機能もあります。
※使用しているAzure PowerShellやAzure CLIのバージョン、REST APIのAPI Versionにより挙動や手順が異なる場合があります。

アラート処理ルールを利用した非監視設定手順についてはこちらに纏めています。
併せて見て頂けると有難いです。

スポンサーリンク