Skip to content

Conversation

@jepetty
Copy link
Contributor

@jepetty jepetty commented Jan 28, 2026

Related command

az containerapp env workload-profile -n <name> -g <resourceGroup> --workload-profile-type flex

Description

This simplifies CLI invocation when creating a new workload-profile for ACA with type flex - the API will automatically assign this profile with a default name, so users don't need to provide one themselves.

Testing Guide

# Create a container environment
az containerapp env create -n <name> -g <resourceGroup>
# Create a flex workload-profile
az containerapp env workload-profile -n <name> -g <resourceGroup> --workload-profile-type flex

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 28, 2026 01:44
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Jan 28, 2026

️✔️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
️✔️postgresql
️✔️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 Jan 28, 2026

⚠️AzureCLI-BreakingChangeTest
⚠️containerapp
rule cmd_name rule_message suggest_message
⚠️ 1009 - ParaPropRemove containerapp env workload-profile add cmd containerapp env workload-profile add update parameter workload_profile_name: removed property required=True

@yonzhan
Copy link
Collaborator

yonzhan commented Jan 28, 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 pull request simplifies the creation of flex workload profiles in Azure Container Apps by making the --workload-profile-name parameter optional when the profile type is "flex". The API automatically assigns a default name for flex profiles, removing the need for users to provide one manually.

Changes:

  • Made workload_profile_name parameter optional in the add_workload_profile function
  • Added validation to require --workload-profile-name only for non-flex workload profile types
  • Updated workload profile setup logic to handle None values for profile names
  • Added comprehensive test case to verify flex profiles can be created without names and non-flex profiles still require names

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

File Description
custom.py Made workload_profile_name parameter optional with default value None, updated duplicate name check to handle None
containerapp_env_decorator.py Added validation requiring profile names only for non-flex types, updated profile matching logic to handle None names
test_containerapp_workload_profile_commands.py Added test verifying flex profiles work without names and non-flex profiles fail without names
Comments suppressed due to low confidence (1)

src/azure-cli/azure/cli/command_modules/containerapp/containerapp_env_decorator.py:311

  • The comment says "flex profiles will be named automatically" but this is an implementation detail of the API, not the CLI. Consider clarifying that the API (not the CLI) assigns the default name, e.g., "workload-profile-name is optional for flex profiles as the API will assign a default name automatically".
        # validate workload profile arguments - flex profiles will be named automatically

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

workload_profile_type = workload_profile_type.upper()
workload_profiles = r["properties"]["workloadProfiles"]
profile = [p for p in workload_profiles if p["name"].lower() == workload_profile_name.lower()]
profile = [p for p in workload_profiles if workload_profile_name and p["name"].lower() == workload_profile_name.lower()]
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

When workload_profile_name is None (for flex profiles), the short-circuit evaluation in the list comprehension ensures that profile will always be an empty list, causing the code to create a new profile at line 389 with {"name": None}. This will serialize to {"name": null} in JSON and be sent to the API. While the test at line 468 suggests the API handles this, it would be more robust to conditionally exclude the "name" key when it's None rather than sending null. Consider changing line 389 to: profile = {} if workload_profile_name is None else {"name": workload_profile_name}, and then conditionally add the name key only when needed.

Copilot uses AI. Check for mistakes.

@AllowLargeResponse(8192)
@ResourceGroupPreparer(location="northcentralus")
def test_containerapp_env_workload_profiles_name_validation(self, resource_group):
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The test function name "test_containerapp_env_workload_profiles_name_validation" doesn't accurately describe what the test does. It's not just testing name validation - it's testing that flex profiles can be created without a name, and that non-flex profiles require a name. Consider renaming to something like "test_containerapp_env_workload_profiles_flex_name_optional" or "test_containerapp_env_workload_profiles_name_requirement" to better reflect the actual test behavior.

Suggested change
def test_containerapp_env_workload_profiles_name_validation(self, resource_group):
def test_containerapp_env_workload_profiles_flex_name_optional(self, resource_group):

Copilot uses AI. Check for mistakes.
workload_profile_type = self.get_argument_workload_profile_type()

if workload_profile_name:
# We have already validated that the configuration is valid if adding a workload profile
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The comment "We have already validated that the configuration is valid if adding a workload profile" is placed at the start of the conditional block, but the validation happens earlier in validate_arguments(). Consider moving or rephrasing this comment to clarify that it's referring to validation that occurred in validate_arguments(), not within this method. Something like "Validation in validate_arguments() ensures this configuration is valid" would be clearer.

Suggested change
# We have already validated that the configuration is valid if adding a workload profile
# Validation in validate_arguments() ensures this configuration is valid when adding a workload profile

Copilot uses AI. Check for mistakes.
@ResourceGroupPreparer(location="northcentralus")
def test_containerapp_env_workload_profiles_name_validation(self, resource_group):
# Set location to a region that supports flex workload profiles
TEST_LOCATION = "northcentralusstage"
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The test uses "northcentralusstage" as the location for testing flex workload profiles. This appears to be a staging environment. Consider documenting whether this test will work in production environments, or if it requires special access to staging. If this is intended only for internal testing, consider adding a skip decorator or condition check.

Copilot uses AI. Check for mistakes.
if workload_profile_name:
# We have already validated that the configuration is valid if adding a workload profile
if workload_profile_name or workload_profile_type:
if "workloadProfiles" not in r["properties"] or not r["properties"]["workloadProfiles"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please a test to cover this case.

@Greedygre
Copy link
Contributor

Hi @jepetty

Which command this PR for? az containerapp env workload-profile is a command group, not a command.

I reviewed this PR, the change is related to command az containerapp env update -n <name> -g <resourceGroup> --workload-profile-type flex

Please add more test case and description for the PR change.


if workload_profile_name:
# We have already validated that the configuration is valid if adding a workload profile
if workload_profile_name or workload_profile_type:
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this change want support command only input --workload-profile-type without --workload-profile-name?

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