简体   繁体   English

使用 Remove-AzScheduledQueryRule 删除 Azure 警报规则(如果存在)

[英]Remove Azure alert rule if exists using Remove-AzScheduledQueryRule

How do you check if an alert rule exists by its ResourceId, and then remove it.如何通过其 ResourceId 检查是否存在警报规则,然后将其删除。 What is the syntax for the check?检查的语法是什么?

Get-AzScheduledQueryRule -ResourceId "/subscriptions.....Id"    
Remove-AzScheduledQueryRule -ResourceId "/subscriptions/.....Id"

As mentioned in above comments, You can use below PowerShell Script which will validate whether any ScheduledQueryRule is present for that particular ResourceId or not.正如上面评论中提到的,您可以使用下面的 PowerShell 脚本,该脚本将验证该特定 ResourceId 是否存在任何ScheduledQueryRule

if exists it will delete the ScheduledQueryRule for that ResourceId.如果存在,它将删除该 ResourceId 的ScheduledQueryRule

Here is the PowerShell Script:这是 PowerShell 脚本:

Connect-AzAccount
 $rulelist = Get-AzScheduledQueryRule
 foreach($item in $rulelist){
 
 if($item.id -contains "<requiredresourceid>"){
    Remove-AzScheduledQueryRule -ResourceId $item.Id
 }
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Azure负载平衡器中删除入站规则 - How to remove Inbound rule from Azure loadbalancer 在 DevOps 中删除 Azure Analysis Services 防火墙规则 - Remove Azure Analysis Services Firewall Rule in DevOps 如何使用Azure API检索“日志搜索”警报规则 - How to retrieve a “Log Search” alert rule using the Azure API 如何使用 PowerShell 在 Azure 中创建新的警报规则? - How to create a new alert rule in Azure using PowerShell? Azure Log Analytics 工作区警报规则在使用 Azure powershell 禁用警报规则时给出错误网关错误 - Azure Log Analytics workspace alert rule giving bad gateway error while disabling alert rule using Azure powershell Azure 说存在同名的警报规则,但它也说不存在 - Azure says an Alert Rule exists with the same name, but it also says it doesn't 添加 SQL 防火墙规则时的 Azure 警报 - Azure alert when SQL firewall rule added ARM模板中的Azure Application Insights警报规则 - Azure Application Insights Alert Rule in ARM Template 在 azure 中使用 powershell 删除角色分配 - Remove Role assignment using powershell in azure 如何使用 Azure 自动化删除应用服务 - How to remove App Service using Azure Automation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM