Disabling an Activity Log Alert rule changes the rule condition
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
### Describe the bug
When trying to disable an Activity Log Alert rule resource based on [this documentation page](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fcli%2Fazure%2Fmonitor%2Factivity-log%2Falert%3Fview%3Dazure-cli-latest%23az-monitor-activity-log-alert-update-examples&data=05%7C02%7Casafst%40microsoft.com%7C4ae079bb601b4f8af06708dd03b305d8%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638670789612756340%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=FCBZw4U%2BVvxutbfyYp6piHrFxW9wVyPyTV1xN3Jd6kY%3D&reserved=0). Once running the command, the rule condition is changed to something else - to an empty Service Health category. The command should just update the "enabled" property to false.
### Related command
az monitor activity-log alert update -n AlertName -g ResourceGroup --enable false
### Errors
No errors, just wrong behavior.
When trying to disable the alert rule, the alert rule condition is getting overridden to Service Health instead of the original condition.
### Issue script & Debug output
nisreen [ ~ ]$ az monitor activity-log alert update -n newrhalert -g internalrg --enable false --debug
cli.knack.cli: Command arguments: ['monitor', 'activity-log', 'alert', 'update', '-n', 'newrhalert', '-g', 'internalrg', '--enable', 'false', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'monitor': ['azure.cli.command_modules.monitor']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: monitor 0.898 23 69
cli.azure.cli.core: Total (1) 0.898 23 69
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: ai-examples 0.134 1 1 /usr/lib/python3.9/site-packages/azure-cli-extensions/ai-examples
cli.azure.cli.core: Total (1) 0.134 1 1
cli.azure.cli.core: Loaded 24 groups, 70 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : monitor activity-log alert update
cli.azure.cli.core: Command table: monitor activity-log alert update
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/nisreen/.azure/commands/2024-11-20.15-03-12.monitor_activity-log_alert_update.595.log'.
az_command_data_logger: command args: monitor activity-log alert update -n {} -g {} --enable {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x7f59af59a4c0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x7f59af53f4c0>, .add_cache_arguments at 0x7f59af55d3a0>, .update_breaking_change_info at 0x7f59af55d430>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x7f59af55d310>]
urllib3.connectionpool: Starting new HTTP connection (1): localhost:50342
urllib3.connectionpool: http://localhost:50342 "POST /oauth2/token HTTP/1.1" 200 2534
msrestazure.azure_active_directory: MSI: Retrieving a token from http://localhost:50342/oauth2/token, with payload {'resource': 'https://management.core.windows.net/'}
cli.azure.cli.core.auth.adal_authentication: MSIAuthenticationWrapper.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
urllib3.connectionpool: Starting new HTTP connection (1): localhost:50342
urllib3.connectionpool: http://localhost:50342 "POST /oauth2/token HTTP/1.1" 200 2534
msrestazure.azure_active_directory: MSI: Retrieving a token from http://localhost:50342/oauth2/token, with payload {'resource': 'https://management.core.windows.net/'}
cli.azure.cli.core.auth.adal_authentication: Normalize expires_on: '1732119222' -> 1732119222
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/0f6ec245-0427-4118-8ee2-8546740d5efd/resourceGroups/internalrg/providers/Microsoft.Insights/activityLogAlerts/newrhalert?api-version=2020-10-01'
cli.azure.cli.core.sdk.policies: Request method: 'GET'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '8ef8bf16-a750-11ef-9bf1-00155d1fdf56'
cli.azure.cli.core.sdk.policies: 'CommandName': 'monitor activity-log alert update'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '-n -g --enable --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.65.0 (RPM) azsdk-python-core/1.28.0 Python/3.9.19 (Linux-5.10.102.2-microsoft-standard-x86_64-with-glibc2.35) cloud-shell/1.0'
cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/0f6ec245-0427-4118-8ee2-8546740d5efd/resourceGroups/internalrg/providers/Microsoft.Insights/activityLogAlerts/newrhalert?api-version=2020-10-01 HTTP/1.1" 200 622
cli.azure.cli.core.sdk.policies: Response status: 200
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Content-Length': '622'
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies: 'Expires': '-1'
cli.azure.cli.core.sdk.policies: 'Vary': 'Accept-Encoding'
cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': '599e2284-7c52-4ae6-8aae-c0a9425e21ee, 599e2284-7c52-4ae6-8aae-c0a9425e21ee'
cli.azure.cli.core.sdk.policies: 'api-supported-versions': '2017-03-01-preview, 2017-04-01, 2020-10-01, 2023-01-01-preview'
cli.azure.cli.core.sdk.policies: 'Arr-Disable-Session-Affinity': 'true'
cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies: 'X-AspNet-Version': '4.0.30319'
cli.azure.cli.core.sdk.policies: 'X-Powered-By': 'ASP.NET'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-reads': '249'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-global-reads': '3749'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '599e2284-7c52-4ae6-8aae-c0a9425e21ee'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'WESTEUROPE:20241120T150312Z:599e2284-7c52-4ae6-8aae-c0a9425e21ee'
cli.azure.cli.core.sdk.policies: 'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.sdk.policies: 'X-MSEdge-Ref': 'Ref A: 84E567542F0147D090F4B6241428ACA9 Ref B: DB3EDGE3221 Ref C: 2024-11-20T15:03:12Z'
cli.azure.cli.core.sdk.policies: 'Date': 'Wed, 20 Nov 2024 15:03:12 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {
"id": "/subscriptions/0f6ec245-0427-4118-8ee2-8546740d5efd/resourceGroups/internalrg/providers/microsoft.insights/activitylogalerts/newrhalert",
"name": "newrhalert",
"type": "Microsoft.Insights/ActivityLogAlerts",
"location": "global",
"tags": {},
"properties": {
"scopes": [
"/subscriptions/0f6ec245-0427-4118-8ee2-8546740d5efd"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ResourceHealth"
}
]
},
"actions": {
"actionGroups": []
},
"enabled": true,
"description": ""
}
}
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/0f6ec245-0427-4118-8ee2-8546740d5efd/resourceGroups/internalrg/providers/Microsoft.Insights/activityLogAlerts/newrhalert?api-version=2020-10-01'
cli.azure.cli.core.sdk.policies: Request method: 'PUT'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json'
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'Content-Length': '263'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '8ef8bf16-a750-11ef-9bf1-00155d1fdf56'
cli.azure.cli.core.sdk.policies: 'CommandName': 'monitor activity-log alert update'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '-n -g --enable --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.65.0 (RPM) azsdk-python-core/1.28.0 Python/3.9.19 (Linux-5.10.102.2-microsoft-standard-x86_64-with-glibc2.35) cloud-shell/1.0'
cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: {"location": "global", "properties": {"actions": {"actionGroups": []}, "condition": {"allOf": [{"equals": "ServiceHealth", "field": "category"}]}, "description": "", "enabled": false, "scopes": ["/subscriptions/0f6ec245-0427-4118-8ee2-8546740d5efd"]}, "tags": {}}
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/0f6ec245-0427-4118-8ee2-8546740d5efd/resourceGroups/internalrg/providers/Microsoft.Insights/activityLogAlerts/newrhalert?api-version=2020-10-01 HTTP/1.1" 200 622
cli.azure.cli.core.sdk.policies: Response status: 200
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Content-Length': '622'
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies: 'Expires': '-1'
cli.azure.cli.core.sdk.policies: 'Vary': 'Accept-Encoding'
cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': '058bc280-ccb7-43b8-8e70-7a4add48a9ea, 058bc280-ccb7-43b8-8e70-7a4add48a9ea'
cli.azure.cli.core.sdk.policies: 'api-supported-versions': '2017-03-01-preview, 2017-04-01, 2020-10-01, 2023-01-01-preview'
cli.azure.cli.core.sdk.policies: 'Arr-Disable-Session-Affinity': 'true'
cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies: 'X-AspNet-Version': '4.0.30319'
cli.azure.cli.core.sdk.policies: 'X-Powered-By': 'ASP.NET'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-writes': '199'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-global-writes': '2999'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '058bc280-ccb7-43b8-8e70-7a4add48a9ea'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'WESTEUROPE:20241120T150314Z:058bc280-ccb7-43b8-8e70-7a4add48a9ea'
cli.azure.cli.core.sdk.policies: 'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.sdk.policies: 'X-MSEdge-Ref': 'Ref A: CC2C7251F926414DB982B4240A816E3B Ref B: DB3EDGE3221 Ref C: 2024-11-20T15:03:12Z'
cli.azure.cli.core.sdk.policies: 'Date': 'Wed, 20 Nov 2024 15:03:13 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {
"id": "/subscriptions/0f6ec245-0427-4118-8ee2-8546740d5efd/resourceGroups/internalrg/providers/Microsoft.Insights/activityLogAlerts/newrhalert",
"name": "newrhalert",
"type": "Microsoft.Insights/ActivityLogAlerts",
"location": "global",
"tags": {},
"properties": {
"scopes": [
"/subscriptions/0f6ec245-0427-4118-8ee2-8546740d5efd"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth"
}
]
},
"actions": {
"actionGroups": []
},
"enabled": false,
"description": ""
}
}
cli.knack.cli: Event: CommandInvoker.OnTransformResult [, ]
cli.knack.cli: Event: CommandInvoker.OnFilterResult []
{
"actions": {
"actionGroups": []
},
"condition": {
"allOf": [
{
"equals": "ServiceHealth",
"field": "category"
}
]
},
"description": "",
"enabled": false,
"id": "/subscriptions/0f6ec245-0427-4118-8ee2-8546740d5efd/resourceGroups/internalrg/providers/Microsoft.Insights/activityLogAlerts/newrhalert",
"location": "global",
"name": "newrhalert",
"resourceGroup": "internalrg",
"scopes": [
"/subscriptions/0f6ec245-0427-4118-8ee2-8546740d5efd"
],
"tags": {},
"type": "Microsoft.Insights/ActivityLogAlerts"
}
cli.knack.cli: Event: Cli.SuccessfulExecute []
cli.knack.cli: Event: Cli.PostExecute []
az_command_data_logger: exit code: 0
cli.__main__: Command ran in 3.333 seconds (init: 0.211, invoke: 3.122)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3956 in cache file under /home/nisreen/.azure/telemetry/20241120150314149
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/usr/bin/python3.9 /usr/lib/az/lib/python3.9/site-packages/azure/cli/telemetry/__init__.py /home/nisreen/.azure /home/nisreen/.azure/telemetry/20241120150314149"
telemetry.process: Return from creating process 606
telemetry.main: Finish creating telemetry upload process.
### Expected behavior
The alert rule condition (and the entire payload) stays the same, just the "enabled" field is updated.
### Environment Summary
nisreen [ ~ ]$ az --version
azure-cli 2.65.0 *
core 2.65.0 *
telemetry 1.1.0
Extensions:
ai-examples 0.2.5
ml 2.30.1
ssh 2.0.5
Dependencies:
msal 1.31.0
azure-mgmt-resource 23.1.1
Python location '/usr/bin/python3.9'
Extensions directory '/home/nisreen/.azure/cliextensions'
Extensions system directory '/usr/lib/python3.9/site-packages/azure-cli-extensions'
Python (Linux) 3.9.19 (main, Aug 23 2024, 00:07:48)
[GCC 11.2.0]
Legal docs and information: aka.ms/AzureCliLegal
You have 2 update(s) available. They will be updated with the next build of Cloud Shell.
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.