Repository navigation
{AKS} aks-preview: align KMS PMK/CMK with 2026-07-02-preview API - #10472
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
CMK-only public-network updates can reintroduce a vault resource ID that the API contract requires to be empty.
2 open findings
What changed in this PR
Aligns AKS preview KMS options with the 2026-07-02-preview API contract.
Changes:
- Restricts infrastructure encryption to
Enabled. - Documents and warns about versioned KMS key IDs.
- Updates KMS handling and related tests.
| File | Description |
|---|---|
HISTORY.rst |
Records KMS contract changes. |
test_managed_cluster_decorator.py |
Updates PMK/CMK unit tests. |
test_aks_commands.py |
Adds a live key-ID migration scenario. |
managed_cluster_decorator.py |
Updates PMK/CMK profile handling. |
custom.py |
Removes the create-time disabled default. |
_validators.py |
Warns for versioned key IDs. |
_params.py |
Restricts accepted PMK values. |
_help.py |
Documents KMS semantics and irreversibility. |
_consts.py |
Adds the enabled-value constant. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Hi Bin Xia (@bingosummer), |
|
Please fix CI issues |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
49b362d to
0054a15
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
c0a3a9d to
80f5936
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
Can we get a confirmation that the live_only test has been run successfully? |
80f5936 to
0443b0b
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
0443b0b to
d34fc41
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
d34fc41 to
9adc0e6
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
Getting it to pass live required fixing the test to match the service's actual behavior:
Correction to the description: the test is not |
API version 2026-07-02-preview removes "Disabled" from InfrastructureEncryption: encryption at rest of Kubernetes resource objects using service-managed keys (PMK) can only be turned on. It also gives the Azure Key Vault KMS (CMK) key ID new semantics: an unversioned key ID selects the new KMS experience with automatic key version rotation, while a versioned key ID selects the legacy experience. - `--kms-infrastructure-encryption` only accepts "Enabled" and no longer defaults to "Disabled" on `az aks create`. Passing any other value raises InvalidArgumentValueError. - Warn when a versioned `--azure-keyvault-kms-key-id` is provided, since it selects the legacy KMS experience. - Document versioned vs unversioned key ID behavior in the help of `az aks create/update`, and update HISTORY.rst. - Update unit tests to expect the rejection of "Disabled". - Add live test test_aks_update_kms_cmk_versioned_to_versionless_key_id (with recording): create a legacy-KMS cluster with a versioned key and PMK disabled (via `az rest` on 2026-06-02-preview, since newer API versions enable PMK by default and reject versioned keys), then switch to an unversioned key with PMK enabled, asserting the PMK state after each step. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6d4f7646-8d74-4894-9245-50b685bb447a
9adc0e6 to
bfa31d7
Compare
|
/azp run |
|
Commenter does not have sufficient privileges for PR 10472 in repo Azure/azure-cli-extensions |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |


🤖 PR Validation —⚠️ Review suggested
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
az aks create/az aks update(--kms-infrastructure-encryption,--azure-keyvault-kms-key-id)Description
API version
2026-07-02-previewchanged the KMS PMK/CMK contract:InfrastructureEncryptionwas extracted into its own definition, and both itsDisabledenum value and itsdefault: "Disabled"were removed. Encryption at rest of Kubernetes resource objects using service-managed keys (PMK) can only be turned on — it cannot be turned off once enabled. The same profile also graduated to the stable2026-07-01API.AzureKeyVaultKms.keyIdhas unchanged schema but new documented semantics: an unversioned key identifier selects the new KMS experience with automatic key version rotation, while a versioned key identifier selects the legacy KMS experience.This PR aligns the extension with that contract:
--kms-infrastructure-encryptionnow only acceptsEnabled, and no longer defaults toDisabledon create. PreviouslyDisabledwas accepted on the command line and then silently dropped, so users could believe they had turned PMK off. It now fails fast with an explanatory error.--azure-keyvault-kms-key-idis supplied, since it opts the cluster into the legacy KMS experience.az aks create/updatedocuments the versioned vs unversioned key ID behavior and the irreversibility of PMK.Note: the vendored SDK already targets
2026-07-02-previewand itsInfrastructureEncryptionenum already contains onlyENABLED, so no SDK regeneration is required.Tests
azext_aks_preview/tests/latest/test_managed_cluster_decorator.py: updated the cases that assumed the oldDisabledcontract, added assertions that an explicitDisablednow raisesInvalidArgumentValueError.azext_aks_preview/tests/latest/test_aks_commands.py: addedtest_aks_update_kms_cmk_versioned_to_versionless_key_id(with recording), which:Disabled(public Key Vault, nokeyVaultResourceId). The create goes throughaz reston2026-06-02-preview, because newer API versions enable PMK by default and the service then rejects versioned key IDs (KeyId must not include a version when PMK is enabled).Succeeded, KMS enabled with the versioned key, and PMK not enabled.--azure-keyvault-kms-key-vault-resource-idand--kms-infrastructure-encryption Enabled(the service rejects a versionless key while PMK is disabled:Bad number of segments: 3 (PMK disabled, expected 4)).Enabled.The cluster identity is granted
Key Vault Readeron the vault before create, since the new KMS experience reads the vault by resource ID and a role assignment made just before the update had not propagated in time.Validation performed:
python -m pytest azext_aks_preview/tests/latest/test_managed_cluster_decorator.py azext_aks_preview/tests/latest/test_validators.py -qazdev style aks-previewpython scripts/ci/test_index.py -qAZURE_TEST_RUN_LIVE=true pytest src/aks-preview/azext_aks_preview/tests/latest/test_aks_commands.py -k test_aks_update_kms_cmk_versioned_to_versionless_key_id(live, eastus2euap)General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install azdevrequired)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.jsonautomatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json.