|
28 | 28 | safe_set, safe_get, _ensure_identity_resource_id) |
29 | 29 | from azure.cli.command_modules.containerapp._clients import ManagedEnvironmentClient |
30 | 30 | from azure.cli.command_modules.containerapp._client_factory import handle_non_404_status_code_exception |
| 31 | +from azure.cli.command_modules.containerapp._decorator_utils import load_yaml_file |
31 | 32 | from azure.cli.command_modules.containerapp._utils import is_registry_msi_system |
32 | 33 | from azure.cli.core.commands.client_factory import get_subscription_id |
33 | 34 |
|
@@ -156,10 +157,43 @@ def get_argument_system_assigned(self): |
156 | 157 | def get_argument_user_assigned(self): |
157 | 158 | return self.get_param("mi_user_assigned") |
158 | 159 |
|
| 160 | + def get_argument_probe_yaml(self): |
| 161 | + return self.get_param("probe_yaml") |
| 162 | + |
159 | 163 | # pylint: disable=no-self-use |
160 | 164 | def get_environment_client(self): |
161 | 165 | return ManagedEnvironmentClient |
162 | 166 |
|
| 167 | + def set_up_probes(self): |
| 168 | + probes_def = load_yaml_file(self.get_argument_probe_yaml()) |
| 169 | + if not isinstance(probes_def, dict) or 'probes' not in probes_def: |
| 170 | + raise ValidationError("The probe YAML file must be a dictionary containing a 'probes' key.") |
| 171 | + |
| 172 | + probes_list = probes_def.get('probes') |
| 173 | + if probes_list is None: |
| 174 | + return [] |
| 175 | + if not isinstance(probes_list, list): |
| 176 | + raise ValidationError("The 'probes' key in the probe YAML file must be a list of probes.") |
| 177 | + |
| 178 | + return probes_list |
| 179 | + |
| 180 | + def check_container_related_arguments(self): |
| 181 | + container_related_args = { |
| 182 | + '--args': self.get_argument_args(), |
| 183 | + '--command': self.get_argument_startup_command(), |
| 184 | + '--container-name': self.get_argument_container_name(), |
| 185 | + '--cpu': self.get_argument_cpu(), |
| 186 | + '--env-vars': self.get_argument_env_vars(), |
| 187 | + '--image or -i': self.get_argument_image(), |
| 188 | + '--memory': self.get_argument_memory(), |
| 189 | + '--probe-yaml': self.get_argument_probe_yaml(), |
| 190 | + '--target-port': self.get_argument_target_port(), |
| 191 | + } |
| 192 | + |
| 193 | + for arg_name, arg_value in container_related_args.items(): |
| 194 | + if arg_value is not None: |
| 195 | + raise ValidationError(f"'{arg_name}' can not be set when container type is not 'CustomContainer'.") |
| 196 | + |
163 | 197 |
|
164 | 198 | class SessionPoolCreateDecorator(SessionPoolPreviewDecorator): |
165 | 199 | def validate_arguments(self): |
@@ -339,6 +373,8 @@ def set_up_container(self): |
339 | 373 | if self.get_argument_args() is not None: |
340 | 374 | container_def["args"] = self.get_argument_args() |
341 | 375 | container_def["resources"] = self.set_up_resource() |
| 376 | + if self.get_argument_probe_yaml() is not None: |
| 377 | + container_def["probes"] = self.set_up_probes() |
342 | 378 | return container_def |
343 | 379 |
|
344 | 380 | def set_up_secrets(self): |
@@ -475,6 +511,10 @@ def validate_arguments(self): |
475 | 511 | current_lifecycle_type.lower() != LifecycleType.Timed.name.lower(): |
476 | 512 | raise ValidationError(f"--cooldown-period is not supported for the current --lifecycle-type '{current_lifecycle_type}'.") |
477 | 513 |
|
| 514 | + # Validate container related arguments |
| 515 | + if safe_get(self.existing_pool_def, "properties", "containerType").lower() != ContainerType.CustomContainer.name.lower(): |
| 516 | + self.check_container_related_arguments() |
| 517 | + |
478 | 518 | def update(self): |
479 | 519 | try: |
480 | 520 | return self.client.update( |
@@ -623,6 +663,8 @@ def set_up_container(self, customer_container_template): |
623 | 663 | container_def["resources"]["cpu"] = self.get_argument_cpu() |
624 | 664 | if self.get_argument_memory() is not None: |
625 | 665 | container_def["resources"]["memory"] = self.get_argument_memory() |
| 666 | + if self.get_argument_probe_yaml() is not None: |
| 667 | + container_def["probes"] = self.set_up_probes() |
626 | 668 | return container_def |
627 | 669 |
|
628 | 670 | def set_up_registry_auth_configuration(self, secrets_def, customer_container_template): |
@@ -677,7 +719,8 @@ def has_container_change(self): |
677 | 719 | self.get_argument_memory() is not None or |
678 | 720 | self.get_argument_env_vars() is not None or |
679 | 721 | self.get_argument_args() is not None or |
680 | | - self.get_argument_startup_command() is not None) |
| 722 | + self.get_argument_startup_command() is not None or |
| 723 | + self.get_argument_probe_yaml() is not None) |
681 | 724 |
|
682 | 725 | def has_registry_change(self): |
683 | 726 | return (self.get_argument_registry_server() is not None or |
|
0 commit comments