-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Containerapp] az containerapp env premium-ingress #8677
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
Changes from 13 commits
19892da
c9da7de
862a714
ded2bbe
c776401
1d80cb7
8ed4907
3c70d18
b041f9f
557be61
c508477
a765883
e0df94c
9b358d2
716dc61
569366e
9d034e4
2696bd3
821976e
9101c5a
53ca52b
2956016
849c933
6b50960
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -291,3 +291,9 @@ def load_command_table(self, args): | |
| with self.command_group('containerapp revision label') as g: | ||
| g.custom_command('add', 'add_revision_label') | ||
| g.custom_command('remove', 'remove_revision_label') | ||
|
|
||
| with self.command_group('containerapp env premium-ingress', is_preview=True) as g: | ||
| g.custom_show_command('show', 'show_environment_premium_ingress') | ||
| g.custom_command('add', 'add_environment_premium_ingress') | ||
| g.custom_command('update', 'update_environment_premium_ingress') | ||
| g.custom_command('remove', 'remove_environment_premium_ingress') | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3710,3 +3710,129 @@ def remove_revision_label(cmd, resource_group_name, name, label, no_wait=False): | |
| return r['properties']['configuration']['ingress']['traffic'] | ||
| except Exception as e: | ||
| handle_raw_exception(e) | ||
|
|
||
|
|
||
| def show_environment_premium_ingress(cmd, name, resource_group_name): | ||
| _validate_subscription_registered(cmd, CONTAINER_APPS_RP) | ||
|
|
||
| try: | ||
| env = ManagedEnvironmentPreviewClient.show(cmd, resource_group_name, name) | ||
| if not env: | ||
| raise ResourceNotFoundError(f"The containerapp environment '{name}' does not exist") | ||
|
||
|
|
||
| ingress_config = safe_get(env, "properties", "ingressConfiguration") | ||
| if not ingress_config: | ||
| return {"message": "No premium ingress configuration found for this environment, using default values."} | ||
|
|
||
| return ingress_config | ||
| except Exception as e: | ||
| handle_raw_exception(e) | ||
|
|
||
|
|
||
| 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): | ||
| _validate_subscription_registered(cmd, CONTAINER_APPS_RP) | ||
|
|
||
| try: | ||
| env = ManagedEnvironmentPreviewClient.show(cmd, resource_group_name, name) | ||
| if not env: | ||
| raise ResourceNotFoundError(f"The containerapp environment '{name}' does not exist") | ||
|
|
||
| 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 | ||
| ingress_config["headerCountLimit"] = header_count_limit | ||
|
|
||
| result = ManagedEnvironmentPreviewClient.update( | ||
| cmd=cmd, | ||
| resource_group_name=resource_group_name, | ||
| name=name, | ||
| managed_environment_envelope=env_patch, | ||
| no_wait=no_wait | ||
| ) | ||
|
|
||
| return safe_get(result, "properties", "ingressConfiguration") | ||
|
|
||
| except Exception as e: | ||
| handle_raw_exception(e) | ||
|
|
||
|
|
||
| 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: | ||
| env = ManagedEnvironmentPreviewClient.show(cmd, resource_group_name, name) | ||
| if not env: | ||
| raise ResourceNotFoundError(f"The containerapp environment '{name}' does not exist") | ||
|
|
||
| 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 | ||
| 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: | ||
| ingress_config["requestIdleTimeout"] = request_idle_timeout | ||
| if header_count_limit is not None: | ||
| ingress_config["headerCountLimit"] = header_count_limit | ||
|
|
||
| # Only add ingressConfiguration to the patch if any values were specified | ||
| if ingress_config: | ||
| safe_set(env_patch, "properties", "ingressConfiguration", value=ingress_config) | ||
| else: | ||
| return {"message": "No changes specified for premium ingress configuration"} | ||
|
|
||
| # Update the environment with the patched ingress configuration | ||
| result = ManagedEnvironmentPreviewClient.update( | ||
| cmd=cmd, | ||
| resource_group_name=resource_group_name, | ||
| name=name, | ||
| managed_environment_envelope=env_patch, | ||
| no_wait=no_wait | ||
| ) | ||
|
|
||
| return safe_get(result, "properties", "ingressConfiguration") | ||
|
|
||
| except Exception as e: | ||
| handle_raw_exception(e) | ||
|
|
||
|
|
||
| def remove_environment_premium_ingress(cmd, name, resource_group_name, no_wait=False): | ||
| _validate_subscription_registered(cmd, CONTAINER_APPS_RP) | ||
|
|
||
| try: | ||
| env = ManagedEnvironmentPreviewClient.show(cmd, resource_group_name, name) | ||
| if not env: | ||
| raise ResourceNotFoundError(f"The containerapp environment '{name}' does not exist") | ||
|
|
||
| env_patch = {} | ||
| # Remove the whole section to restore defaults | ||
| safe_set(env_patch, "properties", "ingressConfiguration", value=None) | ||
|
|
||
| ManagedEnvironmentPreviewClient.update( | ||
| cmd=cmd, | ||
| resource_group_name=resource_group_name, | ||
| name=name, | ||
| managed_environment_envelope=env_patch, | ||
| no_wait=no_wait | ||
| ) | ||
|
|
||
| except Exception as e: | ||
| handle_raw_exception(e) | ||
Uh oh!
There was an error while loading. Please reload this page.