Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于在azure portal中创建新资源时获取通知的PowerShell脚本_Azure_Powershell_Azure Powershell_Azure Alerts - Fatal编程技术网

用于在azure portal中创建新资源时获取通知的PowerShell脚本

用于在azure portal中创建新资源时获取通知的PowerShell脚本,azure,powershell,azure-powershell,azure-alerts,Azure,Powershell,Azure Powershell,Azure Alerts,我需要为任何资源创建创建警报并通过邮件发送给我。 我需要使用powershell脚本执行此操作。配置活动日志警报。配置警报后,即可发送电子邮件 如果希望从powershell配置这些警报,请使用这些commandlet。提及 $condition1=新AzaActivityLocalerCondition-字段“类别”-等于“管理” $condition2=新的AzaActivityLocalerCondition-字段“operationName”-等于“Microsoft.Compute/V

我需要为任何资源创建创建警报并通过邮件发送给我。
我需要使用powershell脚本执行此操作。

配置活动日志警报。配置警报后,即可发送电子邮件

如果希望从powershell配置这些警报,请使用这些commandlet。提及

$condition1=新AzaActivityLocalerCondition-字段“类别”-等于“管理”
$condition2=新的AzaActivityLocalerCondition-字段“operationName”-等于“Microsoft.Compute/VirtualMachine/write”
$additionalWebhookProperties=New Object“System.Collections.Generic.Dictionary``2[System.String,System.String]”
$additionalWebhookProperties.Add('customProperty','someValue')
$actionGrp1=New AzActionGroup-ActionGroupId'/subscriptions//providers/Microsoft.Insights/actiongr1'-WebhookProperty$additionalWebhookProperties
在VM上设置AzaActivityLogalert-Location'Global'-Name'警报创建'-ResourceGroupName'myResourceGroup'-Scope'/subscriptions/'-Action$actionGrp1-条件$condition1,$condition2

如果有帮助,请告诉我。

请告诉我们到目前为止您尝试了什么,以及您遇到的任何问题。检查此项并
$condition1 = New-AzActivityLogAlertCondition -Field 'category' -Equal 'Administrative'
$condition2 = New-AzActivityLogAlertCondition -Field 'operationName' -Equal 'Microsoft.Compute/virtualMachines/write'
$additionalWebhookProperties = New-Object "System.Collections.Generic.Dictionary``2[System.String,System.String]"
$additionalWebhookProperties.Add('customProperty', 'someValue')
$actionGrp1 = New-AzActionGroup -ActionGroupId '/subscriptions/<subid>/providers/Microsoft.Insights/actiongr1' -WebhookProperty $additionalWebhookProperties
Set-AzActivityLogAlert -Location 'Global' -Name 'alert on VM create' -ResourceGroupName 'myResourceGroup' -Scope '/subscriptions/<subid>' -Action $actionGrp1 -Condition $condition1, $condition2