-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[ContainerApp] az containerapp env create: Update the error display for CO environment creation #32648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
Validation for Azure CLI Full Test Starting...
Thanks for your contribution! |
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
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). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
There was a problem hiding this 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 improves the error message displayed when users attempt to create a Consumption-Only Container Apps environment with a name that matches an existing Workload Profiles environment. Previously, users would see a confusing error "At least 1 workload profile must be specified"; now they receive a clear message explaining that the existing environment uses workload profiles and suggesting they create a new one.
Changes:
- Enhanced validation logic to detect when a Consumption-Only environment creation conflicts with an existing Workload Profiles environment
- Added test coverage for the new validation error message
- Removed unused imports from test files
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/containerapp/containerapp_env_decorator.py | Refactored workload profile setup to check for existing environments earlier and added validation for the Consumption-Only conflict scenario |
| src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_env_commands.py | Added test case to verify new error message and imported ValidationError exception |
| src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_compose_registries.py | Removed unused create_containerapp_env import |
| src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_compose_environment.py | Removed unused create_containerapp_env import |
| src/azure-cli/azure/cli/command_modules/containerapp/tests/latest/test_containerapp_compose_basic.py | Removed unused create_containerapp_env import |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| raise ValidationError( | ||
| f"Existing environment {self.get_argument_name()} uses workload profiles. If you want to use Consumption-Only environment, please create a new one.") |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The else block should only raise an error when the user explicitly specifies --enable-workload-profiles false, not when it's unspecified (None). Currently, if a user runs 'az containerapp env create -n test -g rg' without specifying --enable-workload-profiles, and an existing workload-profiles environment exists, they'll get an error about trying to create a Consumption-Only environment even though they didn't explicitly request one. Consider adding a check similar to line 239-242 that only raises the error when '--enable-workload-profiles' is in safe_params, and returning early otherwise to maintain idempotency.
| raise ValidationError( | |
| f"Existing environment {self.get_argument_name()} uses workload profiles. If you want to use Consumption-Only environment, please create a new one.") | |
| # check if input params include -w/--enable-workload-profiles | |
| if self.cmd.cli_ctx.data.get('safe_params') and ('-w' in self.cmd.cli_ctx.data.get( | |
| 'safe_params') or '--enable-workload-profiles' in self.cmd.cli_ctx.data.get('safe_params')): | |
| raise ValidationError( | |
| f"Existing environment {self.get_argument_name()} uses workload profiles. If you want to use Consumption-Only environment, please create a new one.") | |
| return |
Related command
az containerapp env create --name --resource-group --enable-workload-profiles false
Description
This is a small change to make the error message clearer for users when they try to create a ConsumptionOnly environment but an existing WorkloadProfiles environment with the same name already exists. The previous error was "At least 1 workload profile must be specified" - very confusing
Testing Guide
History Notes
[Component Name 1] BREAKING CHANGE:
az command a: Make some customer-facing breaking change[Component Name 2]
az command b: Add some customer-facing featureThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.