Closed sakkuntyo closed 8 months ago
Thank you for opening this issue, we will look into it.
@sakkuntyo I tested in my env and found this can delete the actionGroups property using az monitor activity-log alert update -n aaaa -g bbbb --remove actions.actionGroups
, if that's what you want.
But yes, --remove actions
cannot delete the actions property directly, please remove its inner property instead.
It worked. Thank you!
Describe the bug
Related command
az monitor activity-log alert update
Errors
(ActionGroupsIsNull) The actionGroups is null Activity ID: 11a71619-ac15-435a-84bf-b18e8e950ff6. Code: ActionGroupsIsNull Message: The actionGroups is null Activity ID: 11a71619-ac15-435a-84bf-b18e8e950ff6.
Issue script & Debug output
cli.knack.cli: Command arguments: ['monitor', 'activity-log', 'alert', 'update', '--ids', '/subscriptions/11b4afdb-3329-42f2-b8dc-b26c5ac19146/resourceGroups/DefaultResourceGroup-EJP/providers/microsoft.insights/activityLogAlerts/dasasaki-activitylogalert-sample', '--remove', 'actions', '--debug'] cli.knack.cli: init debug log: Enable color in terminal. Enable VT mode. cli.knack.cli: Event: Cli.PreExecute [] cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x0000028C94F73880>, <function OutputProducer.on_global_arguments at 0x0000028C950FA020>, <function CLIQuery.on_global_arguments at 0x0000028C9511FBA0>] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'monitor': ['azure.cli.command_modules.monitor', 'azext_alertsmanagement', 'azext_scheduled_query'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: monitor 0.646 23 69 cli.azure.cli.core: Total (1) 0.646 23 69 cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next'] cli.azure.cli.core: Loading extensions: cli.azure.cli.core: Name Load Time Groups Commands Directory cli.azure.cli.core: alertsmanagement 0.015 4 6 C:\Users\dasasaki.azure\cliextensions\alertsmanagement cli.azure.cli.core: scheduled-query 0.008 2 5 C:\Users\dasasaki.azure\cliextensions\scheduled-query cli.azure.cli.core: Total (2) 0.022 6 11 cli.azure.cli.core: Loaded 27 groups, 80 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 [<function AzCliLogging.init_command_file_logging at 0x0000028C9804AD40>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\dasasaki.azure\commands\2024-03-29.16-04-29.monitor_activity-log_alert_update.5056.log'. az_command_data_logger: command args: monitor activity-log alert update --ids {} --remove {} --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x0000028C9807F240>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x0000028C980C5300>, <function register_cache_arguments..add_cache_arguments at 0x0000028C980C5440>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x0000028C950FA0C0>, <function CLIQuery.handle_query_parameter at 0x0000028C9511FC40>, <function register_ids_argument..parse_ids_arguments at 0x0000028C980C53A0>]
cli.azure.cli.core.auth.persistence: build_persistence: location='C:\Users\dasasaki\.azure\msal_token_cache.bin', encrypt=True
cli.azure.cli.core.auth.binary_cache: load: C:\Users\dasasaki.azure\msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: openid_config = {'token_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/kerberos', 'tenant_region_scope': 'WW', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
msal.application: Broker enabled? None
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_authentication: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), claims=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 2864a526-42bd-4d68-b204-b4107c41ab56
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/11b4afdb-3329-42f2-b8dc-b26c5ac19146/resourceGroups/DefaultResourceGroup-EJP/providers/Microsoft.Insights/activityLogAlerts/dasasaki-activitylogalert-sample?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': '95a6c3f0-ed9a-11ee-bf02-6c6a77799784'
cli.azure.cli.core.sdk.policies: 'CommandName': 'monitor activity-log alert update'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '--ids --remove --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.58.0 (MSI) azsdk-python-core/1.28.0 Python/3.11.7 (Windows-10-10.0.22631-SP0)'
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/11b4afdb-3329-42f2-b8dc-b26c5ac19146/resourceGroups/DefaultResourceGroup-EJP/providers/Microsoft.Insights/activityLogAlerts/dasasaki-activitylogalert-sample?api-version=2020-10-01 HTTP/1.1" 200 1071
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': '1071'
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': 'b31b0bb0-5056-48b0-91dd-72d628389c42, b31b0bb0-5056-48b0-91dd-72d628389c42'
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': '11999'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': 'b31b0bb0-5056-48b0-91dd-72d628389c42'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'JAPANEAST:20240329T070431Z:b31b0bb0-5056-48b0-91dd-72d628389c42'
cli.azure.cli.core.sdk.policies: 'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.sdk.policies: 'X-MSEdge-Ref': 'Ref A: FB318586CC694B7C899AECF8E8C00F53 Ref B: TYO201100117029 Ref C: 2024-03-29T07:04:30Z'
cli.azure.cli.core.sdk.policies: 'Date': 'Fri, 29 Mar 2024 07:04:30 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {
"id": "/subscriptions/11b4afdb-3329-42f2-b8dc-b26c5ac19146/resourceGroups/DefaultResourceGroup-EJP/providers/microsoft.insights/activitylogalerts/dasasaki-activitylogalert-sample",
"name": "dasasaki-activitylogalert-sample",
"type": "Microsoft.Insights/ActivityLogAlerts",
"location": "global",
"tags": {},
"properties": {
"scopes": [
"/subscriptions/11b4afdb-3329-42f2-b8dc-b26c5ac19146"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "Administrative"
},
{
"field": "operationName",
"equals": "Microsoft.DocumentDB/databaseAccounts/apis/databases/collections/delete"
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/11b4afdb-3329-42f2-b8dc-b26c5ac19146/resourcegroups/dasasaki-lab/providers/microsoft.insights/actiongroups/dasasaki-ag-teams",
"webhookProperties": {}
}
]
},
"enabled": true,
"description": ""
}
}
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/11b4afdb-3329-42f2-b8dc-b26c5ac19146/resourceGroups/DefaultResourceGroup-EJP/providers/Microsoft.Insights/activityLogAlerts/dasasaki-activitylogalert-sample?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': '357'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '95a6c3f0-ed9a-11ee-bf02-6c6a77799784'
cli.azure.cli.core.sdk.policies: 'CommandName': 'monitor activity-log alert update'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '--ids --remove --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.58.0 (MSI) azsdk-python-core/1.28.0 Python/3.11.7 (Windows-10-10.0.22631-SP0)'
cli.azure.cli.core.sdk.policies: 'Authorization': ''
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: {"location": "global", "properties": {"condition": {"allOf": [{"equals": "ServiceHealth", "field": "category"}, {"equals": "Microsoft.DocumentDB/databaseAccounts/apis/databases/collections/delete", "field": "operationName"}]}, "description": "", "enabled": true, "scopes": ["/subscriptions/11b4afdb-3329-42f2-b8dc-b26c5ac19146"], "actions": {}}, "tags": {}}
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/11b4afdb-3329-42f2-b8dc-b26c5ac19146/resourceGroups/DefaultResourceGroup-EJP/providers/Microsoft.Insights/activityLogAlerts/dasasaki-activitylogalert-sample?api-version=2020-10-01 HTTP/1.1" 400 117
cli.azure.cli.core.sdk.policies: Response status: 400
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': '117'
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: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': 'c8d1257a-ff20-4036-9699-344dbe9f0587'
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': '1199'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': 'c8d1257a-ff20-4036-9699-344dbe9f0587'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'JAPANEAST:20240329T070432Z:c8d1257a-ff20-4036-9699-344dbe9f0587'
cli.azure.cli.core.sdk.policies: 'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.sdk.policies: 'X-MSEdge-Ref': 'Ref A: 29D8087FFF474C22B7BC7A47DE764EAD Ref B: TYO201100117029 Ref C: 2024-03-29T07:04:31Z'
cli.azure.cli.core.sdk.policies: 'Date': 'Fri, 29 Mar 2024 07:04:31 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"code":"ActionGroupsIsNull","message":"The actionGroups is null Activity ID: c8d1257a-ff20-4036-9699-344dbe9f0587."}
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 664, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 731, in _run_jobs_serially
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 701, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_command.py", line 155, in call
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/monitor/aaz/latest/monitor/activity_log/alert/_update.py", line 44, in _handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/monitor/aaz/latest/monitor/activity_log/alert/_update.py", line 194, in _execute_operations
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/monitor/aaz/latest/monitor/activity_log/alert/_update.py", line 309, in call
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/aaz/_operation.py", line 332, in on_error
azure.core.exceptions.HttpResponseError: (ActionGroupsIsNull) The actionGroups is null Activity ID: c8d1257a-ff20-4036-9699-344dbe9f0587.
Code: ActionGroupsIsNull
Message: The actionGroups is null Activity ID: c8d1257a-ff20-4036-9699-344dbe9f0587.
cli.azure.cli.core.azclierror: (ActionGroupsIsNull) The actionGroups is null Activity ID: c8d1257a-ff20-4036-9699-344dbe9f0587. Code: ActionGroupsIsNull Message: The actionGroups is null Activity ID: c8d1257a-ff20-4036-9699-344dbe9f0587. az_command_data_logger: (ActionGroupsIsNull) The actionGroups is null Activity ID: c8d1257a-ff20-4036-9699-344dbe9f0587. Code: ActionGroupsIsNull Message: The actionGroups is null Activity ID: c8d1257a-ff20-4036-9699-344dbe9f0587. cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x0000028C9804AFC0>] az_command_data_logger: exit code: 1 cli.main: Command ran in 3.993 seconds (init: 0.495, invoke: 3.498) 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 3866 in cache telemetry.main: Begin creating telemetry upload process. telemetry.process: Creating upload process: "C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry__init__.pyc C:\Users\dasasaki.azure" telemetry.process: Return from creating process telemetry.main: Finish creating telemetry upload process.
Expected behavior
It is expected that the update will be successfully accomplished in the form of the action group being deleted.
Environment Summary
{ "azure-cli": "2.58.0", "azure-cli-core": "2.58.0", "azure-cli-telemetry": "1.1.0", "extensions": { "alertsmanagement": "0.2.3", "scheduled-query": "0.5.2" } }
Additional context
Due to the reasons below, the validation of the ARM template for activitylogalerts seems to be different from other metric alert rules and log alert rules. Therefore, the cause might not be Azure CLI, but rather in activitylogalerts.
The --remove actions function in the same way as "az monitor metrics alert update" and "az monitor scheduled-query update".
It seems to be changing to "actions": {}, but activitylogalerts appears to require the following format.
need to delete the property named "actions" itself.