Skip to content

[AKS] az aks update: Add support to remove existing certificates by setting the value of --custom-ca-trust-certificates to an empty file#32201

Merged
yanzhudd merged 4 commits intoAzure:devfrom
UtheMan:mikolaj/remove-ca
Oct 14, 2025
Merged

[AKS] az aks update: Add support to remove existing certificates by setting the value of --custom-ca-trust-certificates to an empty file#32201
yanzhudd merged 4 commits intoAzure:devfrom
UtheMan:mikolaj/remove-ca

Conversation

@UtheMan
Copy link
Contributor

@UtheMan UtheMan commented Sep 30, 2025

Related command
az aks update

Description
Customers can now use CLI to completely remove certificates passed using custom-ca-trust-certificates field.

Testing Guide
azdev test --live acs.test_aks_update_remove_custom_ca_trust_certificates

History Notes
N/A

Copilot AI review requested due to automatic review settings September 30, 2025 18:36
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Sep 30, 2025

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

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

azure-client-tools-bot-prd bot commented Sep 30, 2025

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Collaborator

yonzhan commented Sep 30, 2025

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

@github-actions
Copy link

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>

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality to the Azure CLI's az aks update command to allow complete removal of custom CA trust certificates by passing an empty file to the custom-ca-trust-certificates parameter.

  • Modified the update logic to handle empty certificate files for removal
  • Added comprehensive test coverage for the new removal functionality
  • Updated both unit tests and integration tests to verify the behavior

Reviewed Changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.

File Description
managed_cluster_decorator.py Updated the certificate update logic to allow setting empty certificates when parameter is explicitly provided
test_managed_cluster_decorator.py Added unit test to verify removal of certificates using empty file
test_aks_commands.py Added integration test to verify end-to-end certificate removal functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@yonzhan
Copy link
Collaborator

yonzhan commented Oct 1, 2025

Please fix CI issues

@FumingZhang FumingZhang changed the title az aks update: Add option to remove certificates passed to custom-ca-trust-certificates field by passing an empty file [AKS] az aks update: Add option to remove certificates passed to custom-ca-trust-certificates field by passing an empty file Oct 1, 2025
@FumingZhang FumingZhang changed the title [AKS] az aks update: Add option to remove certificates passed to custom-ca-trust-certificates field by passing an empty file [AKS] az aks update: Add support to remove existing certificates by setting the value of --custom-ca-trust-certificates to an empty file Oct 1, 2025
Comment on lines +8714 to +8715
if self.context.raw_param.get("custom_ca_trust_certificates") is not None:
ca_certs = self.context.get_custom_ca_trust_certificates()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's a good idea to allow this option to accept an empty string as a value, and that would also remove the existing certificates. But there might be a chance user is doing so by mistake (compared to provided an emtpy file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified this to block when empty string is passed


@AllowLargeResponse()
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='westus2')
def test_aks_update_remove_custom_ca_trust_certificates(self, resource_group, resource_group_location):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the live test failed with following error

E azure.cli.testsdk.exceptions.JMESPathCheckAssertionError: Query 'securityProfile.customCaTrustCertificates' doesn't yield expected value '['testcert', 'testcert']', instead the actual value is '['-----BEGIN CERTIFICATE-----\nxxxx\n-----END CERTIFICATE-----']'. Data:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can mark the test case as @live_only(), so it won't run in replay mode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified the recording files instead to allow replay tests to pass.

@UtheMan UtheMan force-pushed the mikolaj/remove-ca branch from ceb43d2 to 3e2b627 Compare October 9, 2025 17:57
@FumingZhang
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd yanzhudd merged commit cb808a1 into Azure:dev Oct 14, 2025
48 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants