Skip to content

[AKS] az aks update: Add option --assignee-principal-type to specify the principal type when using --attach-acr#31464

Merged
yanzhudd merged 8 commits intoAzure:devfrom
jovieir:dev
Jun 23, 2025
Merged

[AKS] az aks update: Add option --assignee-principal-type to specify the principal type when using --attach-acr#31464
yanzhudd merged 8 commits intoAzure:devfrom
jovieir:dev

Conversation

@jovieir
Copy link
Copy Markdown
Contributor

@jovieir jovieir commented May 13, 2025

Related command
az aks update --attach-acr

Description

This commit introduces a new parameter, --assignee-principal-type, to the az aks update --attach-acr command in the Azure CLI, allowing users to explicitly specify the principal type (e.g., User, Group, or ServicePrincipal) for ACR role assignment. This enhancement aims to address Role-Based Access Control (RBAC)-related errors by ensuring the correct principal type is applied during the ACR role assignment, specifically when using Azure RBAC role assignment conditions

The original --attach-acr parameter omits the principalType from the requestBody, which causes the authorization request to be invalidated when used with role assignment conditions.

The original logic is not changed, as to not break existing implementation. The optional parameter, when used, overrides the default behavior to ensure the correct principal type is applied during the ACR role assignment.

Testing Guide

  1. Create an AKS cluster
  2. Setup an Azure role assignment condition dependent on one of the expected principalTypes. eg:
    ( ( !(ActionMatches{'Microsoft.Authorization/roleAssignments/write'}) ) OR ( @Request[Microsoft.Authorization/roleAssignments:PrincipalType] ForAnyOfAnyValues:StringEqualsIgnoreCase {'ServicePrincipal', 'Group'}) )
  3. Run az aks update -g <rg> -n <cluster_name> --attach-acr <acr name> and notice the 403 Unauthorized exception from ARM.
  4. Re-run the command with the new parameter --assignee-principal-type and the expected principalType and the command succeeds.

History Notes

[AKS] az aks update: Add option --assignee-principal-type to specify the principal type when using --attach-acr


This checklist is used to make sure that common guidelines for a pull request are followed.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented May 13, 2025

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.9
️✔️acs
️✔️latest
️✔️3.12
️✔️3.9
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.9
️✔️ams
️✔️latest
️✔️3.12
️✔️3.9
️✔️apim
️✔️latest
️✔️3.12
️✔️3.9
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.9
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️aro
️✔️latest
️✔️3.12
️✔️3.9
️✔️backup
️✔️latest
️✔️3.12
️✔️3.9
️✔️batch
️✔️latest
️✔️3.12
️✔️3.9
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.9
️✔️billing
️✔️latest
️✔️3.12
️✔️3.9
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.9
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.9
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.9
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.9
️✔️config
️✔️latest
️✔️3.12
️✔️3.9
️✔️configure
️✔️latest
️✔️3.12
️✔️3.9
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.9
️✔️container
️✔️latest
️✔️3.12
️✔️3.9
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.9
️✔️core
️✔️latest
️✔️3.12
️✔️3.9
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.9
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.9
️✔️dls
️✔️latest
️✔️3.12
️✔️3.9
️✔️dms
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.9
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.9
️✔️find
️✔️latest
️✔️3.12
️✔️3.9
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.9
️✔️identity
️✔️latest
️✔️3.12
️✔️3.9
️✔️iot
️✔️latest
️✔️3.12
️✔️3.9
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.9
️✔️lab
️✔️latest
️✔️3.12
️✔️3.9
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️maps
️✔️latest
️✔️3.12
️✔️3.9
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.9
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.9
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.9
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.9
️✔️network
️✔️latest
️✔️3.12
️✔️3.9
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.9
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.9
️✔️profile
️✔️latest
️✔️3.12
️✔️3.9
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.9
️✔️redis
️✔️latest
️✔️3.12
️✔️3.9
️✔️relay
️✔️latest
️✔️3.12
️✔️3.9
️✔️resource
️✔️latest
️✔️3.12
️✔️3.9
️✔️role
️✔️latest
️✔️3.12
️✔️3.9
️✔️search
️✔️latest
️✔️3.12
️✔️3.9
️✔️security
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.9
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.9
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.9
️✔️sql
️✔️latest
️✔️3.12
️✔️3.9
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.9
️✔️storage
️✔️latest
️✔️3.12
️✔️3.9
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.9
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.9
️✔️util
️✔️latest
️✔️3.12
️✔️3.9
️✔️vm
️✔️latest
️✔️3.12
️✔️3.9

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Hi @jovieir,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented May 13, 2025

⚠️AzureCLI-BreakingChangeTest
⚠️acs
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd aks update cmd aks update added parameter assignee_principal_type

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented May 13, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@FumingZhang
Copy link
Copy Markdown
Member

/azp run

@jovieir jovieir changed the title Add optional parameter --assignee-principal-type to az aks update --attach-acr [AKS] Add optional parameter --assignee-principal-type to az aks update --attach-acr May 26, 2025
@jovieir
Copy link
Copy Markdown
Contributor Author

jovieir commented May 26, 2025

/azp run

@azure-pipelines
Copy link
Copy Markdown

Commenter does not have sufficient privileges for PR 31464 in repo Azure/azure-cli

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented May 26, 2025

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@jovieir jovieir changed the title [AKS] Add optional parameter --assignee-principal-type to az aks update --attach-acr [AKS] Add optional parameter --assignee-principal-type to az aks update --attach-acr May 27, 2025
@jovieir
Copy link
Copy Markdown
Contributor Author

jovieir commented May 27, 2025

ok - last commit should fix CI errors

@FumingZhang
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@jovieir
Copy link
Copy Markdown
Contributor Author

jovieir commented May 28, 2025

not sure why the title PR is failing - the fixes are there?

[Azure CLI] Add optional parameter --assignee-principal-type to az aks update --attach-acr : missing around --assignee-principal-type ↑ ↑ [Azure CLI] Add optional parameter --assignee-principal-type to az aks update --attach-acr : missing around az aks update --attach-acr
↑ ↑
[Azure CLI] Add optional parameter --assignee-principal-type to az aks update --attach-acr : missing ` around --attach-acr
↑ ↑
[Azure CLI] Add optional parameter --assignee-principal-type to az aks update --attach-acr : please delete the last character

@jovieir
Copy link
Copy Markdown
Contributor Author

jovieir commented May 29, 2025

pebkac - fixed history notes...

@FumingZhang
Copy link
Copy Markdown
Member

[AKS] `az aks update`: Add option `--assignee-principal-type` to specify the principal type when using `--attach-acr`

something like this is preferred by the CI check
https://github.com/Azure/azure-cli/tree/dev/doc/authoring_command_modules#format-pr-title

@jovieir jovieir changed the title [AKS] Add optional parameter --assignee-principal-type to az aks update --attach-acr [AKS] az aks update: Add option --assignee-principal-type to specify the principal type when using --attach-acr May 29, 2025
@jovieir
Copy link
Copy Markdown
Contributor Author

jovieir commented May 29, 2025

Thanks @FumingZhang - Looks like CI was complaining about the resource history part on the body - and I was assuming it was the title. I've updated the title anyway as yours look better. :-)

@jovieir
Copy link
Copy Markdown
Contributor Author

jovieir commented May 29, 2025

I understand we missed the milestone but anyway, could you re-run the tests @FumingZhang? Thanks!

@FumingZhang
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@jovieir
Copy link
Copy Markdown
Contributor Author

jovieir commented Jun 3, 2025

accidentally introduced a whitespace which caused the PR to fail. My bad - could you rerun one last time @FumingZhang ? thanks

@FumingZhang
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd yanzhudd merged commit 1ee4df8 into Azure:dev Jun 23, 2025
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AKS az aks/acs/openshift Auto-Assign Auto assign by bot Container Registry az acr Portal az portal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants