{Role} Remove code for classic events #16581
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
az role assignment list-changelogs(introduced by #5551) calls Activity Logs - List to get all activity logs with$filter=resourceProvider eq Microsoft.Authorization.Then it uses
azure-cli/src/azure-cli/azure/cli/command_modules/role/custom.py
Line 422 in 00c59c2
to retrieve the subscription ID from mgmt client for Classic Administrator events. This operation is not permitted by Track 2 SDKs, as
confignow becomes a protected_configattribute.Classic Administrator events
Classic Administrator create/delete operation generates 2 types of logs:
ARM event with
http_requestattributeCLI currently doesn't show this type, because
operation_nameof the event is'Microsoft.Authorization/classicadministrators/write'and the event will be filtered out:azure-cli/src/azure-cli/azure/cli/command_modules/role/custom.py
Line 353 in 00c59c2
"offline" event without
http_requestattributeCLI currently doesn't show this type either, because
item.event_name.valueshould be'Microsoft.Authorization/classicAdministrators/write'instead.azure-cli/src/azure-cli/azure/cli/command_modules/role/custom.py
Line 327 in 00c59c2
Conclusion
Therefore, Classic Administrator event will not be shown by the current Azure CLI at all. Adding them back will instead cause a BREAKING CHANGE, as Classic Administrator event has different structure as ARM role assignment event:
Classic Administrator event:
{ "caller": "Subscription Admin", "principalId": null, "principalName": "[email protected]", "principalType": "User", "roleDefinitionId": null, "roleName": "CoAdmin", "scope": "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590", "scopeName": "0b1f6471-1bf0-4dda-aec3-cb9272f09590", "scopeType": "Subscription", "timestamp": "2021-01-19T07:10:56.932598+00:00" }ARM role assignment event:
{ "action": "Revoked", // Classic Administrator event doesn't have this field "caller": "[email protected]", "principalId": "5e914469-5dcf-4f7d-b2b6-ba14e926daba", "principalName": "http://azure-cli-2020-12-04-08-00-43", "roleDefinitionId": "b24988ac-6180-42a0-ab88-20f7382dd24c", "roleName": "Contributor", "scope": "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590", "scopeName": "0b1f6471-1bf0-4dda-aec3-cb9272f09590", "scopeType": "Subscription", "timestamp": "2021-01-19T05:38:43.228672+00:00" }Also
Microsoft.Authorization/classicAdministrators/deleteevent doesn't haveadminEmailfield.principalNamewill be left asnull.{ "caller": "Subscription Admin", "principalId": null, "principalName": null, "principalType": "User", "roleDefinitionId": null, "roleName": null, "scope": "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590", "scopeName": "0b1f6471-1bf0-4dda-aec3-cb9272f09590", "scopeType": "Subscription", "timestamp": "2021-01-19T07:13:15.805340+00:00" }To query it, we have to call Classic Administrators - List which will of course add more complexity.
Changes
Since Azure CLI doesn't support creating Classic Administrator assignment or showing Classic Administrator events, this PR removes the logic for Classic Administrator event.
Testing guide
Run this command from both current CLI and changed CLI, the result number should be the same (849 in
/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590).Additional information
The only public API for
classicAdministratorsis Classic Administrators - List.The
Classic Administrators - PUTAPI which Azure Portal calls is not publicly documented.netId(e.g.1003200042CF7CB1) is an internal property of a user which is not exposed by AD Graph API v1.6 Operations on users.Azure Portal queries it with an internal API: