Skip to content

[Container] az container create: Remove default values for container group to support standby pool reuse scenario#31824

Merged
zhoxing-ms merged 6 commits intoAzure:devfrom
drishtipeshwani09:bug-containerinstance/2024-05-01-preview
Jul 24, 2025
Merged

[Container] az container create: Remove default values for container group to support standby pool reuse scenario#31824
zhoxing-ms merged 6 commits intoAzure:devfrom
drishtipeshwani09:bug-containerinstance/2024-05-01-preview

Conversation

@drishtipeshwani09
Copy link
Member

@drishtipeshwani09 drishtipeshwani09 commented Jul 16, 2025

Related command
The changes are related to this command - az container create

Description

  • Ideally, we should not be initializing any default values on our end for the standby pool reuse scenario case which was introduced in API Version - 2024-05-01-preview.
  • However, a bug was identified where we are still setting up values for properties like ports, protocol and ip address which has been fixed.
  • This is an expected behavior when standby pool profile id is provided.

Testing Guide
Currently, while we try to reuse a cg from a given standby pool with delegated subnet, we get the below error -

Code: BadRequest
Message: ContainerGroup properties other than config map are not allowed

This change would fix that, now if a customer runs the following command for example, they should be able to reuse a cg successfully -

az container create --resource-group rg --name ctn --container-group-profile-id {cgprofile-id} --container-group-profile-revision {revision-number} --standby-pool-profile-id {standbypoolprofile-id} --vnet {vnet-name/id} --subnet {subnet-name/id}

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 July 16, 2025 08:32
@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Jul 16, 2025

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.9
️✔️acs
️✔️latest
️✔️3.12
️✔️3.9
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.9
️✔️ams
️✔️latest
️✔️3.12
️✔️3.9
️✔️apim
️✔️latest
️✔️3.12
️✔️3.9
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.9
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️aro
️✔️latest
️✔️3.12
️✔️3.9
️✔️backup
️✔️latest
️✔️3.12
️✔️3.9
️✔️batch
️✔️latest
️✔️3.12
️✔️3.9
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.9
️✔️billing
️✔️latest
️✔️3.12
️✔️3.9
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.9
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.9
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.9
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.9
️✔️config
️✔️latest
️✔️3.12
️✔️3.9
️✔️configure
️✔️latest
️✔️3.12
️✔️3.9
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.9
️✔️container
️✔️latest
️✔️3.12
️✔️3.9
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.9
️✔️core
️✔️latest
️✔️3.12
️✔️3.9
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.9
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.9
️✔️dls
️✔️latest
️✔️3.12
️✔️3.9
️✔️dms
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.9
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.9
️✔️find
️✔️latest
️✔️3.12
️✔️3.9
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.9
️✔️identity
️✔️latest
️✔️3.12
️✔️3.9
️✔️iot
️✔️latest
️✔️3.12
️✔️3.9
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.9
️✔️lab
️✔️latest
️✔️3.12
️✔️3.9
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️maps
️✔️latest
️✔️3.12
️✔️3.9
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.9
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.9
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.9
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.9
️✔️network
️✔️latest
️✔️3.12
️✔️3.9
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.9
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.9
️✔️profile
️✔️latest
️✔️3.12
️✔️3.9
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.9
️✔️redis
️✔️latest
️✔️3.12
️✔️3.9
️✔️relay
️✔️latest
️✔️3.12
️✔️3.9
️✔️resource
️✔️latest
️✔️3.12
️✔️3.9
️✔️role
️✔️latest
️✔️3.12
️✔️3.9
️✔️search
️✔️latest
️✔️3.12
️✔️3.9
️✔️security
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.9
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.9
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.9
️✔️sql
️✔️latest
️✔️3.12
️✔️3.9
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.9
️✔️storage
️✔️latest
️✔️3.12
️✔️3.9
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.9
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.9
️✔️util
️✔️latest
️✔️3.12
️✔️3.9
️✔️vm
️✔️latest
️✔️3.12
️✔️3.9

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

azure-client-tools-bot-prd bot commented Jul 16, 2025

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Collaborator

yonzhan commented Jul 16, 2025

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

Updates the az container create command to avoid setting default network values when a standby pool profile ID is provided, enabling proper reuse of standby pools.

  • Clear vnet_address_prefix and subnet_address_prefix when standby_pool_profile_id is supplied
  • Move default assignment of ports and protocol into the non-standby code path
  • Only create cgroup_ip_address if not in a standby pool scenario
Comments suppressed due to low confidence (1)

src/azure-cli/azure/cli/command_modules/container/custom.py:146

  • Add a test case for the standby pool reuse scenario to verify that no default ports, protocol, or IP address are set when standby_pool_profile_id is provided.
    if standby_pool_profile_id != None:

Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

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

Use is not None when comparing to None for better readability and to follow PEP8 conventions.

Suggested change
if standby_pool_profile_id != None:
if standby_pool_profile_id is not None:

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

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

This assignment is redundant and can be removed since it does not change the value of ports.

Suggested change
ports = ports

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

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

This assignment is a no-op and should be removed to simplify the code.

Suggested change
protocol = protocol

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

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

Use is None when checking against None to align with Python best practices.

Suggested change
if standby_pool_profile_id == None:
if standby_pool_profile_id is None:

Copilot uses AI. Check for mistakes.
@drishtipeshwani09 drishtipeshwani09 changed the title [Container] Remove default values for az container create operation to support standby pool reuse scenario [Container] az container create: Remove default values for container group to support standby pool reuse scenario Jul 16, 2025
@zhoxing-ms
Copy link
Contributor

Please add some test cases for this PR change

Comment on lines 150 to 151
Copy link
Contributor

Choose a reason for hiding this comment

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

May I ask why design this assignment logic?

Copy link
Member Author

@drishtipeshwani09 drishtipeshwani09 Jul 21, 2025

Choose a reason for hiding this comment

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

Thanks for pointing this out!! There was a mistake in this logic, I have modified this such that only when the standby pool profile id is null, and the port/protocol variables are null as well, we want to assign the variables default values, otherwise they will remain null.

Co-authored-by: Xing Zhou <Zhou.Xing@microsoft.com>
@zhoxing-ms
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@zhoxing-ms zhoxing-ms merged commit d60e9d2 into Azure:dev Jul 24, 2025
48 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments