Skip to content

Conversation

@ShantingLiu
Copy link
Contributor

@ShantingLiu ShantingLiu commented Nov 17, 2025

Related command
az aks safeguards create, az aks safeguards update, az aks safeguards show, az aks safeguards list, az aks safeguards delete, az aks safeguards wait

Description
This PR adds Pod Security Standards (PSS) support to Azure CLI's AKS deployment safeguards commands, preparing them for GA release.

Key Changes:

  1. Pod Security Standards Parameter: Added --pss-level parameter to create and update commands supporting Baseline, Privileged, and Restricted levels
  2. Pre-existence Validation: Added validation in create command to prevent duplicate resource creation with clear error messaging
  3. Enhanced Parameter Support: Fixed all safeguards commands to support -g/-n syntax in addition to --managed-cluster --c --cluster
  4. API Version Update: Updated all commands from 2025-04-01 to 2025-05-02-preview API
  5. Test Updates: Re-recorded test with live Azure resources

Related PRs:

Testing Guide

# Create safeguards with PSS level
az aks safeguards create -g myResourceGroup -n myCluster --level Warn --pss-level Baseline

# Create safeguards again to check if pre-existence check worked (should error)
az aks safeguards create -g myResourceGroup -n myCluster --level Warn --pss-level Baseline

# Update PSS level
az aks safeguards update -g myResourceGroup -n myCluster --pss-level Restricted

# Show safeguards (works with -g/-n syntax)
az aks safeguards show -g myResourceGroup -n myCluster

# List safeguards
az aks safeguards list -g myResourceGroup -n myCluster

# Delete safeguards
az aks safeguards delete -g myResourceGroup -n myCluster

History Notes
[AKS] az aks safeguards: Add --pss-level parameter to support Pod Security Standards
[AKS] az aks safeguards create: Add validation to prevent duplicate resource creation


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

Copilot AI review requested due to automatic review settings November 17, 2025 22:39
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Nov 17, 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

@yonzhan
Copy link
Collaborator

yonzhan commented Nov 17, 2025

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

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

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

@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>

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

azure-client-tools-bot-prd bot commented Nov 17, 2025

⚠️AzureCLI-BreakingChangeTest
⚠️acs
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd aks safeguards create cmd aks safeguards create added parameter pss_level
⚠️ 1006 - ParaAdd aks safeguards update cmd aks safeguards update added parameter pss_level
⚠️ 1009 - ParaPropRemove aks safeguards wait cmd aks safeguards wait update parameter managed_cluster: removed property required=True

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 Pod Security Standards (PSS) support to Azure CLI's AKS deployment safeguards commands, preparing them for GA release by updating the API version to 2025-05-02-preview and introducing the --pss-level parameter.

Key Changes:

  • Added --pss-level parameter to create and update commands supporting Baseline, Privileged, and Restricted PSS levels
  • Implemented pre-existence validation in the create command to prevent duplicate safeguards resources
  • Updated API version from 2025-04-01 to 2025-05-02-preview across all safeguards commands with flattened properties schema

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
_create.py Added --pss-level parameter, pre-existence validation logic, updated API version to 2025-05-02-preview, added skip_quote=True for resource URI handling
_update.py Added nullable --pss-level parameter, updated API version, added schema helper class to reduce duplication, added skip_quote=True
_show.py Updated API version to 2025-05-02-preview, added pod_security_standards_level to schema, set client_flatten flag, added skip_quote=True
_list.py Updated API version to 2025-05-02-preview, added pod_security_standards_level to schema, set client_flatten flag, added skip_quote=True
_delete.py Updated API version to 2025-05-02-preview, updated docstring examples to use "Deletes", added skip_quote=True
_wait.py Updated API version to 2025-05-02-preview, added pod_security_standards_level to schema, set client_flatten flag, added skip_quote=True
test_aks_safeguards.py Updated test assertions to use flattened properties paths (e.g., level instead of properties.level)
HISTORY.rst Added history notes for new --pss-level parameter and pre-existence validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@FumingZhang
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@FumingZhang
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@ShantingLiu
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

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

@FumingZhang
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

- Reverted all client_flatten=True to client_flatten=False to maintain backward compatibility
- Fixed AAZ undefined check to use has_value() instead of fragile string comparison
- Fixed list command to return both result and next_link
- Updated test assertions to use properties.* paths for nested structure
- No breaking changes to JSON output - properties remain nested
Following the same pattern as managed namespaces, add a pre-existence check
in the AKSSafeguardsCreateCustom.pre_operations() method that prevents
creating duplicate Deployment Safeguards instances. Uses send_raw_request
to check if the resource exists before proceeding with creation.

Also adds get_container_service_client to imports for consistency.
…commands

- Add -c/--cluster options back to safeguards create command
- Update validation to handle both cluster names and full resource IDs
- Fix pre_operations execution order in _execute_operations
- Add --pss-level parameter support with Baseline/Restricted values
- Update test to use -c/-g syntax and test PSS level functionality
- Re-record test with live Azure resources
- Change 'Creates' to 'Create'
- Change 'Deletes' to 'Delete'
- Change 'Gets' to 'Get'
- Keep all command flags unchanged
- Moved pre-existence check from _create.py to AKSSafeguardsCreateCustom.pre_operations()
- This prevents the logic from being wiped when AAZ regenerates the command files
- Custom logic now survives AAZ regeneration as it's in custom.py
- Re-recorded tests with new implementation (13 minutes, passed)
- Update all safeguards commands (create, show, update, delete, list, wait) to use 2025-07-01 GA API version
- Remove is_preview=True flags since commands now use GA API
- Fix -g/-n parameter support by setting required=False for managed_cluster argument
- Update test recordings for new API version
- Resolves 'The command is in development' error by using GA API instead of preview

All CRUD operations tested and working:
- Show: Displays proper nested properties structure
- Delete: Clean deletion without errors
- Create: Successfully creates with level and PSS parameters
- Update: All parameters working (--level, --pss-level, --excluded-ns)
- Custom error handling preserved for duplicate creates
- Remove is_preview=True from aks and aks safeguards command groups
- Update API version retrieval to use direct access without defaults
- Re-record test with GA API version (2025-07-01)
The recording was created with live mode which captured the real subscription ID.
Replace with 00000000-0000-0000-0000-000000000000 for CI pipeline compatibility.
- Regenerated all AAZ safeguards files from workspace editor with 2025-07-01 GA API
- AAZ files now properly have required=True for managed_cluster argument
- Fixed custom.py to use ._required instead of .required for proper override
- Updated test recording with GA API version (2025-07-01)
- All CRUD operations work with both -c and -g/-n syntax
@FumingZhang
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

These attributes were added attempting to fix the -c required issue but didn't work. Removing them as they serve no purpose and CRUD operations work correctly without them.
@FumingZhang
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd yanzhudd merged commit bc15429 into Azure:dev Nov 22, 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