-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Container App] az containerapp env: Add http-route-config and premium-ingress
#32240
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 all commits
c0fcd20
8d78c98
b9f7e81
ca36678
b829266
a67f61d
532789c
4198f22
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 |
|---|---|---|
|
|
@@ -1641,3 +1641,104 @@ | |
| --environment MyContainerappEnv \\ | ||
| --compose-file-path "path/to/docker-compose.yml" | ||
| """ | ||
|
|
||
| # Routing | ||
| helps['containerapp env http-route-config'] = """ | ||
| type: group | ||
| short-summary: Commands to manage environment level http routing. | ||
| """ | ||
|
|
||
| helps['containerapp env http-route-config list'] = """ | ||
| type: command | ||
| short-summary: List the http route configs in the environment. | ||
| examples: | ||
| - name: List the http route configs in the environment. | ||
| text: | | ||
| az containerapp env http-route-config list -g MyResourceGroup -n MyEnvironment | ||
| """ | ||
|
|
||
| helps['containerapp env http-route-config create'] = """ | ||
| type: command | ||
| short-summary: Create a new http route config. | ||
|
Comment on lines
+1660
to
+1662
|
||
| examples: | ||
| - name: Create a new route from a yaml file. | ||
| text: | | ||
| az containerapp env http-route-config create -g MyResourceGroup -n MyEnvironment -r configname --yaml config.yaml | ||
| """ | ||
|
|
||
| helps['containerapp env http-route-config update'] = """ | ||
| type: command | ||
| short-summary: Update a http route config. | ||
|
Comment on lines
+1669
to
+1671
|
||
| examples: | ||
| - name: Update a route in the environment from a yaml file. | ||
| text: | | ||
| az containerapp env http-route-config update -g MyResourceGroup -n MyEnvironment -r configname --yaml config.yaml | ||
| """ | ||
|
|
||
| helps['containerapp env http-route-config show'] = """ | ||
| type: command | ||
| short-summary: Show a http route config. | ||
|
Comment on lines
+1678
to
+1680
|
||
| examples: | ||
| - name: Show a route in the environment. | ||
| text: | | ||
| az containerapp env http-route-config show -g MyResourceGroup -n MyEnvironment -r configname | ||
| """ | ||
|
|
||
| helps['containerapp env http-route-config delete'] = """ | ||
| type: command | ||
| short-summary: Delete a http route config. | ||
|
Comment on lines
+1687
to
+1689
|
||
| examples: | ||
| - name: Delete a route from the environment. | ||
| text: | | ||
| az containerapp env http-route-config delete -g MyResourceGroup -n MyEnvironment -r configname | ||
| """ | ||
|
|
||
| # Ingress | ||
| helps['containerapp env premium-ingress show'] = """ | ||
| type: command | ||
| short-summary: Show the premium ingress settings for the environment. | ||
|
Comment on lines
+1697
to
+1699
|
||
| examples: | ||
| - name: Show the premium ingress settings for the environment. | ||
| text: | | ||
| az containerapp env premium-ingress show -g MyResourceGroup -n MyEnvironment | ||
| """ | ||
|
|
||
| helps['containerapp env premium-ingress'] = """ | ||
| type: group | ||
| short-summary: Configure premium ingress settings for the environment. | ||
| long-summary: | | ||
| Premium ingress settings apply to all applications in the environment. They allow moving the ingress instances to a workload profile and scaling them beyond the system defaults to enable high traffic workloads. Other settings include request idle timeouts, header count limits, and the termination grace period. | ||
| examples: | ||
| - name: Enable premium ingress for the environment. | ||
| text: | | ||
| az containerapp env premium-ingress add -g MyResourceGroup -n MyEnvironment -w WorkloadProfileName | ||
| """ | ||
|
|
||
| helps['containerapp env premium-ingress add'] = """ | ||
| type: command | ||
| short-summary: Enable the premium ingress settings for the environment. | ||
|
Comment on lines
+1717
to
+1719
|
||
| long-summary: | | ||
| Unspecified optional parameters will be cleared from any existing configuration. | ||
| examples: | ||
| - name: Add the premium ingress settings for the environment. | ||
| text: | | ||
| az containerapp env premium-ingress add -g MyResourceGroup -n MyEnvironment -w WorkloadProfileName | ||
| """ | ||
|
|
||
| helps['containerapp env premium-ingress update'] = """ | ||
| type: command | ||
| short-summary: Update the premium ingress settings for the environment. | ||
|
Comment on lines
+1728
to
+1730
|
||
| examples: | ||
| - name: Update the workload profile used for premium ingress. | ||
| text: | | ||
| az containerapp env premium-ingress update -g MyResourceGroup -n MyEnvironment -w WorkloadProfileName | ||
| """ | ||
|
|
||
| helps['containerapp env premium-ingress remove'] = """ | ||
| type: command | ||
| short-summary: Remove the ingress settings and restores the system to default values. | ||
|
Comment on lines
+1737
to
+1739
|
||
| examples: | ||
| - name: Reset the ingress settings for the environment to its default values | ||
| text: | | ||
| az containerapp env premium-ingress remove -g MyResourceGroup -n MyEnvironment | ||
| """ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,7 @@ | |
| AuthClient, | ||
| WorkloadProfileClient, | ||
| ContainerAppsJobClient, | ||
| HttpRouteConfigClient, | ||
| SubscriptionClient | ||
| ) | ||
| from ._github_oauth import get_github_access_token | ||
|
|
@@ -5088,3 +5089,160 @@ def delete_workload_profile(cmd, resource_group_name, env_name, workload_profile | |
| return r | ||
| except Exception as e: | ||
| handle_raw_exception(e) | ||
|
|
||
|
|
||
| def create_http_route_config(cmd, resource_group_name, name, http_route_config_name, yaml): | ||
| _validate_subscription_registered(cmd, CONTAINER_APPS_RP) | ||
| yaml_http_route_config = load_yaml_file(yaml) | ||
| # check if the type is dict | ||
| if not isinstance(yaml_http_route_config, dict): | ||
| raise ValidationError('Invalid YAML provided. Please see https://aka.ms/azure-container-apps-yaml for a valid YAML spec.') | ||
|
|
||
| http_route_config_envelope = {"properties": yaml_http_route_config} | ||
|
|
||
| try: | ||
| return HttpRouteConfigClient.create(cmd, resource_group_name, name, http_route_config_name, http_route_config_envelope) | ||
| except Exception as e: | ||
| handle_raw_exception(e) | ||
|
|
||
|
|
||
| def update_http_route_config(cmd, resource_group_name, name, http_route_config_name, yaml): | ||
| _validate_subscription_registered(cmd, CONTAINER_APPS_RP) | ||
| yaml_http_route_config = load_yaml_file(yaml) | ||
| # check if the type is dict | ||
| if not isinstance(yaml_http_route_config, dict): | ||
| raise ValidationError('Invalid YAML provided. Please see https://aka.ms/azure-container-apps-yaml for a valid YAML spec.') | ||
|
|
||
| http_route_config_envelope = {"properties": yaml_http_route_config} | ||
|
|
||
| try: | ||
| return HttpRouteConfigClient.update(cmd, resource_group_name, name, http_route_config_name, http_route_config_envelope) | ||
| except Exception as e: | ||
| handle_raw_exception(e) | ||
|
|
||
|
|
||
| def list_http_route_configs(cmd, resource_group_name, name): | ||
| _validate_subscription_registered(cmd, CONTAINER_APPS_RP) | ||
| try: | ||
| return HttpRouteConfigClient.list(cmd, resource_group_name, name) | ||
| except Exception as e: | ||
| handle_raw_exception(e) | ||
|
|
||
|
|
||
| def show_http_route_config(cmd, resource_group_name, name, http_route_config_name): | ||
| _validate_subscription_registered(cmd, CONTAINER_APPS_RP) | ||
| try: | ||
| return HttpRouteConfigClient.show(cmd, resource_group_name, name, http_route_config_name) | ||
| except Exception as e: | ||
| handle_raw_exception(e) | ||
|
|
||
|
|
||
| def delete_http_route_config(cmd, resource_group_name, name, http_route_config_name): | ||
| _validate_subscription_registered(cmd, CONTAINER_APPS_RP) | ||
| try: | ||
| return HttpRouteConfigClient.delete(cmd, resource_group_name, name, http_route_config_name) | ||
| 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 = ManagedEnvironmentClient.show(cmd, resource_group_name, name) | ||
| 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=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: | ||
| ManagedEnvironmentClient.show(cmd, resource_group_name, name) | ||
| env_patch = {} | ||
| ingress_config = {} | ||
| safe_set(env_patch, "properties", "ingressConfiguration", value=ingress_config) | ||
|
|
||
| # Required | ||
| ingress_config["workloadProfileName"] = workload_profile_name | ||
| # Optional, remove if None | ||
| ingress_config["terminationGracePeriodSeconds"] = termination_grace_period | ||
| ingress_config["requestIdleTimeout"] = request_idle_timeout | ||
| ingress_config["headerCountLimit"] = header_count_limit | ||
|
|
||
| result = ManagedEnvironmentClient.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): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| _validate_subscription_registered(cmd, CONTAINER_APPS_RP) | ||
|
|
||
| try: | ||
| ManagedEnvironmentClient.show(cmd, resource_group_name, name) | ||
| env_patch = {} | ||
| ingress_config = {} | ||
|
|
||
| if workload_profile_name is not None: | ||
| ingress_config["workloadProfileName"] = workload_profile_name | ||
| 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 = ManagedEnvironmentClient.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: | ||
| ManagedEnvironmentClient.show(cmd, resource_group_name, name) | ||
| env_patch = {} | ||
| # Remove the whole section to restore defaults | ||
| safe_set(env_patch, "properties", "ingressConfiguration", value=None) | ||
|
|
||
| ManagedEnvironmentClient.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) | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The help message should start with an active voice verb. Change 'List the http route configs' to 'List http route configs'.