Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Release History
===============
upcoming
++++++
* 'az containerapp env premium-ingress': remove `--min-replicas` and `--max-replicas` parameters, use workload profile scale instead.
* 'az containerapp session code-interpreter execute': Extend maximum supported value of `--timeout-in-seconds` from 60 to 220.
* 'az containerapp job create': Fix message with `--help`
* 'az containerapp arc': Enable setup custom core dns for Openshift on Arc
Expand Down
4 changes: 2 additions & 2 deletions src/containerapp/azext_containerapp/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,7 @@
examples:
- name: Enable premium ingress for the environment.
text: |
az containerapp env premium-ingress add -g MyResourceGroup -n MyEnvironment -w WorkloadProfileName
az containerapp env premium-ingress add -g MyResourceGroup -n MyEnvironment -w WorkloadProfileName --min-replicas 2 --max-replicas 10
"""

helps['containerapp env premium-ingress add'] = """
Expand All @@ -2395,7 +2395,7 @@
examples:
- name: Add the premium ingress settings for the environment.
text: |
az containerapp env premium-ingress add -g MyResourceGroup -n MyEnvironment -w WorkloadProfileName
az containerapp env premium-ingress add -g MyResourceGroup -n MyEnvironment -w WorkloadProfileName --min-replicas 2 --max-replicas 10
"""

helps['containerapp env premium-ingress update'] = """
Expand Down
2 changes: 2 additions & 0 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ def load_arguments(self, _):
c.argument('resource_group_name', arg_type=resource_group_name_type, id_part=None)
c.argument('name', options_list=['--name', '-n'], help="The name of the managed environment.")
c.argument('workload_profile_name', options_list=['--workload-profile-name', '-w'], help="The workload profile to run ingress replicas on. This profile must not be shared with any container app or job.")
c.argument('min_replicas', options_list=['--min-replicas'], type=int, help="Minimum number of replicas to run. Default 2, minimum 2.")
c.argument('max_replicas', options_list=['--max-replicas'], type=int, help="Maximum number of replicas to run. Default 10. The upper limit is the maximum cores available in the workload profile.")
c.argument('termination_grace_period', options_list=['--termination-grace-period', '-t'], type=int, help="Time in seconds to drain requests during ingress shutdown. Default 500, minimum 0, maximum 3600.")
c.argument('request_idle_timeout', options_list=['--request-idle-timeout'], type=int, help="Timeout in minutes for idle requests. Default 4, minimum 1.")
c.argument('header_count_limit', options_list=['--header-count-limit'], type=int, help="Limit of http headers per request. Default 100, minimum 1.")
15 changes: 13 additions & 2 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3844,17 +3844,21 @@ def show_environment_premium_ingress(cmd, name, resource_group_name):
handle_raw_exception(e)


def add_environment_premium_ingress(cmd, name, resource_group_name, workload_profile_name, termination_grace_period=None, request_idle_timeout=None, header_count_limit=None, no_wait=False):
def add_environment_premium_ingress(cmd, name, resource_group_name, workload_profile_name, min_replicas, max_replicas, termination_grace_period=None, request_idle_timeout=None, header_count_limit=None, no_wait=False):
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

The min_replicas and max_replicas parameters are required (no default values) but the help text in _params.py suggests defaults ("Default 2" and "Default 10"). This inconsistency could confuse users about whether these parameters are required or optional.

Copilot uses AI. Check for mistakes.
_validate_subscription_registered(cmd, CONTAINER_APPS_RP)

try:
ManagedEnvironmentPreviewClient.show(cmd, resource_group_name, name)
env_patch = {}
ingress_config = {}
safe_set(env_patch, "properties", "ingressConfiguration", value=ingress_config)
scale = {}
ingress_config["scale"] = scale

# Required
ingress_config["workloadProfileName"] = workload_profile_name
scale["minReplicas"] = min_replicas
scale["maxReplicas"] = max_replicas
# Optional, remove if None
ingress_config["terminationGracePeriodSeconds"] = termination_grace_period
ingress_config["requestIdleTimeout"] = request_idle_timeout
Expand All @@ -3874,16 +3878,23 @@ def add_environment_premium_ingress(cmd, name, resource_group_name, workload_pro
handle_raw_exception(e)


def update_environment_premium_ingress(cmd, name, resource_group_name, workload_profile_name=None, termination_grace_period=None, request_idle_timeout=None, header_count_limit=None, no_wait=False):
def update_environment_premium_ingress(cmd, name, resource_group_name, workload_profile_name=None, min_replicas=None, max_replicas=None, termination_grace_period=None, request_idle_timeout=None, header_count_limit=None, no_wait=False):
_validate_subscription_registered(cmd, CONTAINER_APPS_RP)

try:
ManagedEnvironmentPreviewClient.show(cmd, resource_group_name, name)
env_patch = {}
ingress_config = {}
scale = {}

if workload_profile_name is not None:
ingress_config["workloadProfileName"] = workload_profile_name
if min_replicas is not None:
ingress_config["scale"] = scale
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

The scale dictionary is assigned to ingress_config multiple times (lines 3893 and 3896). This creates duplicate code that could be consolidated by checking if either min_replicas or max_replicas is not None before creating the scale object once.

Copilot uses AI. Check for mistakes.
scale["minReplicas"] = min_replicas
if max_replicas is not None:
ingress_config["scale"] = scale
scale["maxReplicas"] = max_replicas
if termination_grace_period is not None:
ingress_config["terminationGracePeriodSeconds"] = termination_grace_period
if request_idle_timeout is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,30 +673,38 @@ def test_containerapp_env_premium_ingress_commands(self, resource_group):
JMESPathCheck('message', 'No premium ingress configuration found for this environment, using default values.'),
])

self.cmd(f'containerapp env premium-ingress add -g {resource_group} -n {env_name} -w wp-ingress', checks=[
self.cmd(f'containerapp env premium-ingress add -g {resource_group} -n {env_name} -w wp-ingress --min-replicas 3 --max-replicas 5', checks=[
JMESPathCheck('workloadProfileName', 'wp-ingress'),
JMESPathCheck('scale.minReplicas', 3),
JMESPathCheck('scale.maxReplicas', 5),
JMESPathCheck('terminationGracePeriodSeconds', None),
JMESPathCheck('requestIdleTimeout', None),
JMESPathCheck('headerCountLimit', None),
])

self.cmd(f'containerapp env premium-ingress show -g {resource_group} -n {env_name}', checks=[
JMESPathCheck('workloadProfileName', 'wp-ingress'),
JMESPathCheck('scale.minReplicas', 3),
JMESPathCheck('scale.maxReplicas', 5),
JMESPathCheck('terminationGracePeriodSeconds', None),
JMESPathCheck('requestIdleTimeout', None),
JMESPathCheck('headerCountLimit', None),
])

self.cmd(f'containerapp env premium-ingress update -g {resource_group} -n {env_name} --termination-grace-period 45 --request-idle-timeout 180 --header-count-limit 40', checks=[
self.cmd(f'containerapp env premium-ingress update -g {resource_group} -n {env_name} --min-replicas 4 --max-replicas 20 --termination-grace-period 45 --request-idle-timeout 180 --header-count-limit 40', checks=[
JMESPathCheck('workloadProfileName', 'wp-ingress'),
JMESPathCheck('scale.minReplicas', 4),
JMESPathCheck('scale.maxReplicas', 20),
JMESPathCheck('terminationGracePeriodSeconds', 45),
JMESPathCheck('requestIdleTimeout', 180),
JMESPathCheck('headerCountLimit', 40),
])

# set removes unspecified optional parameters
self.cmd(f'containerapp env premium-ingress add -g {resource_group} -n {env_name} -w wp-ingress --request-idle-timeout 90', checks=[
self.cmd(f'containerapp env premium-ingress add -g {resource_group} -n {env_name} -w wp-ingress --min-replicas 2 --max-replicas 3 --request-idle-timeout 90', checks=[
JMESPathCheck('workloadProfileName', 'wp-ingress'),
JMESPathCheck('scale.minReplicas', 2),
JMESPathCheck('scale.maxReplicas', 3),
JMESPathCheck('requestIdleTimeout', 90),
JMESPathCheck('terminationGracePeriodSeconds', None),
JMESPathCheck('headerCountLimit', None),
Expand Down
Loading