Skip to content

Conversation

@jepetty
Copy link

@jepetty jepetty commented Jan 15, 2026

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

  1. Create a workload-profile enabled environment: az containerapp env create --name test --resource-group jepetty-week1 --enable-workload-profiles $true
  2. Run the same command, but with workload-profiles disabled: az containerapp env create --name test --resource-group jepetty-week1 --enable-workload-profiles $false

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 feature


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 January 15, 2026 22:40
@azure-client-tools-bot-prd
Copy link

Validation for Azure CLI Full Test Starting...

Thanks for your contribution!

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

Validation for Breaking Change Starting...

Thanks for your contribution!

@yonzhan
Copy link
Collaborator

yonzhan commented Jan 15, 2026

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

Comment on lines +248 to +249
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.")
Copy link

Copilot AI Jan 15, 2026

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot ContainerApp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants