when i am calling below log alerts azure rest api able to enable/disable only application insights) same api when calling alerts created on log analytics its throwing error "PatchResourceNotFound"
got below error
{
"error": {
"code": "PatchResourceNotFound",
"message": "The resource 'https://management.azure.com/subscriptions/4776c051-f4ef-4a30-8ce7-c9fb99ff0fc5/resourcegroups/DevOpsTestRG-A/providers/microsoft.insights/scheduledQueryRules/Unexpected shutdown?api-version=2018-04-16' was not found when performing the PATCH operation."
}
}
Disable-LogAnalyticsAlertRule {
param(
[Parameter(Position = 0, mandatory = $true)]
[string] $Rulename,
[Parameter(Position = 1, mandatory = $true)]
[string] $ResourceGroupName
)
$headers = Get-AccessTokenFromContext
$cur_sub = (Get-AzureRmContext).Subscription.Id
$ruleUri = "https://management.azure.com/subscriptions/$cur_sub/resourcegroups/$resourceGroupName/providers/microsoft.insights/scheduledQueryRules/$RuleName" + "?api-version=2018-04-16"
$bodyEnable = "
{
'properties': {
'enabled': 'false'
}
}
"
Write-Verbose "ResourceURI being invoked: $ruleUri"
try {
$disablerule = Invoke-RestMethod -Method PATCH -Uri $ruleUri -Headers $headers -Body $bodyEnable
$disablerule | Select-Object @{Name = "displayName"; Expression = { $_.properties.displayName } }, @{Name = "IsEnabled"; Expression = { $_.properties.enabled } }, @{Name = "lastUpdate"; Expression = { $_.properties.lastUpdatedTime } }, @{Name = "provisioningState"; Expression = { $_.properties.provisioningState } } | Format-Table -AutoSize -Wrap
Write-Verbose "Output of Invoke-RestMethod: $disablerule"
}
catch {
Write-Error "$_"
}
}
%20
or-
? – 4c74356b41