diff --git a/src/containerapp/azext_containerapp/_help.py b/src/containerapp/azext_containerapp/_help.py index 2f1780a3b1d..fddce84bda1 100644 --- a/src/containerapp/azext_containerapp/_help.py +++ b/src/containerapp/azext_containerapp/_help.py @@ -405,6 +405,14 @@ --logs-workspace-id myLogsWorkspaceID \\ --logs-workspace-key myLogsWorkspaceKey \\ --location eastus2 + - name: Create an environment with workload profiles enabled. + text: | + az containerapp env create -n MyContainerappEnvironment -g MyResourceGroup \\ + --location eastus2 --enable-workload-profiles + - name: Create an environment without workload profiles enabled. + text: | + az containerapp env create -n MyContainerappEnvironment -g MyResourceGroup \\ + --location eastus2 --enable-workload-profiles false """ helps['containerapp service'] = """ diff --git a/src/containerapp/azext_containerapp/_params.py b/src/containerapp/azext_containerapp/_params.py index 15c93f7860f..8bfd1b9df80 100644 --- a/src/containerapp/azext_containerapp/_params.py +++ b/src/containerapp/azext_containerapp/_params.py @@ -192,7 +192,7 @@ def load_arguments(self, _): with self.argument_context('containerapp env create') as c: c.argument('zone_redundant', options_list=["--zone-redundant", "-z"], help="Enable zone redundancy on the environment. Cannot be used without --infrastructure-subnet-resource-id. If used with --location, the subnet's location must match") - c.argument('enable_workload_profiles', arg_type=get_three_state_flag(), options_list=["--enable-workload-profiles", "-w"], help="Boolean indicating if the environment is enabled to have workload profiles", is_preview=True) + c.argument('enable_workload_profiles', arg_type=get_three_state_flag(), options_list=["--enable-workload-profiles", "-w"], help="Boolean indicating if the environment is enabled to have workload profiles") with self.argument_context('containerapp env update') as c: c.argument('name', name_type, help='Name of the Container Apps environment.') @@ -394,9 +394,9 @@ def load_arguments(self, _): c.argument('consumer_secret_setting_name', options_list=['--consumer-secret-name', '--secret-name'], help='The consumer secret name that contains the app secret.') c.argument('provider_name', required=True, help='The name of the custom OpenID Connect provider.') c.argument('openid_configuration', help='The endpoint that contains all the configuration endpoints for the provider.') - c.argument('token_store', arg_type=get_three_state_flag(), help='Boolean indicating if token store is enabled for the app.') - c.argument('sas_url_secret', help='The blob storage SAS URL to be used for token store.') - c.argument('sas_url_secret_name', help='The secret name that contains blob storage SAS URL to be used for token store.') + c.argument('token_store', arg_type=get_three_state_flag(), help='Boolean indicating if token store is enabled for the app.', is_preview=True) + c.argument('sas_url_secret', help='The blob storage SAS URL to be used for token store.', is_preview=True) + c.argument('sas_url_secret_name', help='The secret name that contains blob storage SAS URL to be used for token store.', is_preview=True) # auth update c.argument('set_string', options_list=['--set'], help='Value of a specific field within the configuration settings for the Azure App Service Authentication / Authorization feature.') diff --git a/src/containerapp/azext_containerapp/commands.py b/src/containerapp/azext_containerapp/commands.py index 1596148e810..f5fa9881dea 100644 --- a/src/containerapp/azext_containerapp/commands.py +++ b/src/containerapp/azext_containerapp/commands.py @@ -26,8 +26,8 @@ def load_command_table(self, _): g.custom_command('exec', 'containerapp_ssh', validator=validate_ssh) g.custom_command('up', 'containerapp_up', supports_no_wait=False, exception_handler=ex_handler_factory()) g.custom_command('browse', 'open_containerapp_in_browser') - g.custom_show_command('show-custom-domain-verification-id', 'show_custom_domain_verification_id') - g.custom_command('list-usages', 'list_usages', table_transformer=transform_usages_output) + g.custom_show_command('show-custom-domain-verification-id', 'show_custom_domain_verification_id', is_preview=True) + g.custom_command('list-usages', 'list_usages', table_transformer=transform_usages_output, is_preview=True) with self.command_group('containerapp replica') as g: g.custom_show_command('show', 'get_replica') # TODO implement the table transformer @@ -44,7 +44,7 @@ def load_command_table(self, _): g.custom_command('create', 'create_managed_environment', supports_no_wait=True, exception_handler=ex_handler_factory()) g.custom_command('delete', 'delete_managed_environment', supports_no_wait=True, confirmation=True, exception_handler=ex_handler_factory()) g.custom_command('update', 'update_managed_environment', supports_no_wait=True, exception_handler=ex_handler_factory()) - g.custom_command('list-usages', 'list_environment_usages', table_transformer=transform_usages_output) + g.custom_command('list-usages', 'list_environment_usages', table_transformer=transform_usages_output, is_preview=True) with self.command_group('containerapp job') as g: g.custom_show_command('show', 'show_containerappsjob') diff --git a/src/containerapp/azext_containerapp/containerapp_env_decorator.py b/src/containerapp/azext_containerapp/containerapp_env_decorator.py index 0193a543bae..b14f2a47aec 100644 --- a/src/containerapp/azext_containerapp/containerapp_env_decorator.py +++ b/src/containerapp/azext_containerapp/containerapp_env_decorator.py @@ -19,7 +19,7 @@ load_cert_file, safe_set, get_default_workload_profiles, - _azure_monitor_quickstart) + _azure_monitor_quickstart, safe_get) from ._client_factory import handle_raw_exception from .base_resource import BaseResource from ._models import ( @@ -96,9 +96,6 @@ def get_argument_certificate_file(self): def get_argument_certificate_password(self): return self.get_param("certificate_password") - def get_argument_enable_workload_profiles(self): - return self.get_param("enable_workload_profiles") - def get_argument_mtls_enabled(self): return self.get_param("mtls_enabled") @@ -167,8 +164,7 @@ def construct_payload(self): self.managed_env_def["tags"] = self.get_argument_tags() self.managed_env_def["properties"]["zoneRedundant"] = self.get_argument_zone_redundant() - if self.get_argument_enable_workload_profiles() is True: - self.managed_env_def["properties"]["workloadProfiles"] = get_default_workload_profiles(self.cmd, self.get_argument_location()) + self.set_up_workload_profiles() # Custom domains if self.get_argument_hostname(): @@ -188,6 +184,9 @@ def construct_payload(self): if self.get_argument_mtls_enabled() is not None: safe_set(self.managed_env_def, "properties", "peerAuthentication", "mtls", "enabled", value=self.get_argument_mtls_enabled()) + def set_up_workload_profiles(self): + self.managed_env_def["properties"]["workloadProfiles"] = get_default_workload_profiles(self.cmd, self.get_argument_location()) + def set_up_app_log_configuration(self): if (self.get_argument_logs_customer_id() is None or self.get_argument_logs_key() is None) and self.get_argument_logs_destination() == "log-analytics": logs_customer_id, logs_key = _generate_log_analytics_if_not_provided(self.cmd, self.get_argument_logs_customer_id(), self.get_argument_logs_key(), @@ -342,3 +341,13 @@ def post_process(self, r): _azure_monitor_quickstart(self.cmd, self.get_argument_name(), self.get_argument_resource_group_name(), self.get_argument_storage_account(), self.get_argument_logs_destination()) return r + + +class ContainerappEnvPreviewCreateDecorator(ContainerAppEnvCreateDecorator): + + def set_up_workload_profiles(self): + if self.get_argument_enable_workload_profiles(): + self.managed_env_def["properties"]["workloadProfiles"] = get_default_workload_profiles(self.cmd, self.get_argument_location()) + + def get_argument_enable_workload_profiles(self): + return self.get_param("enable_workload_profiles") diff --git a/src/containerapp/azext_containerapp/custom.py b/src/containerapp/azext_containerapp/custom.py index 3352214fa46..552d7df2097 100644 --- a/src/containerapp/azext_containerapp/custom.py +++ b/src/containerapp/azext_containerapp/custom.py @@ -34,7 +34,7 @@ from msrest.exceptions import DeserializationError from .containerapp_job_decorator import ContainerAppJobDecorator, ContainerAppJobPreviewCreateDecorator -from .containerapp_env_decorator import ContainerAppEnvDecorator, ContainerAppEnvCreateDecorator, ContainerAppEnvUpdateDecorator +from .containerapp_env_decorator import ContainerAppEnvDecorator, ContainerappEnvPreviewCreateDecorator, ContainerAppEnvUpdateDecorator from .containerapp_auth_decorator import ContainerAppPreviewAuthDecorator from .containerapp_decorator import BaseContainerAppDecorator, ContainerAppPreviewCreateDecorator, ContainerAppPreviewListDecorator, ContainerAppPreviewUpdateDecorator from ._client_factory import handle_raw_exception, handle_non_404_exception @@ -700,7 +700,7 @@ def create_managed_environment(cmd, mtls_enabled=None, no_wait=False): raw_parameters = locals() - containerapp_env_create_decorator = ContainerAppEnvCreateDecorator( + containerapp_env_create_decorator = ContainerappEnvPreviewCreateDecorator( cmd=cmd, client=ManagedEnvironmentClient, raw_parameters=raw_parameters, diff --git a/src/containerapp/azext_containerapp/tests/latest/recordings/test_containerapp_managed_service_binding_e2e.yaml b/src/containerapp/azext_containerapp/tests/latest/recordings/test_containerapp_managed_service_binding_e2e.yaml index d7d370158b3..de37aa77ada 100644 --- a/src/containerapp/azext_containerapp/tests/latest/recordings/test_containerapp_managed_service_binding_e2e.yaml +++ b/src/containerapp/azext_containerapp/tests/latest/recordings/test_containerapp_managed_service_binding_e2e.yaml @@ -4534,7 +4534,7 @@ interactions: - python/3.10.12 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.35) AZURECLI/2.51.0 method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.App/containerApps/containerapp000003?api-version=2023-04-01-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.App/containerApps/containerapp000003?api-version=2023-05-02-preview response: body: string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.App/containerapps/containerapp000003","name":"containerapp000003","type":"Microsoft.App/containerApps","location":"East @@ -4635,7 +4635,7 @@ interactions: - python/3.10.12 (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.35) AZURECLI/2.51.0 method: PATCH - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.App/containerApps/containerapp000003?api-version=2023-04-01-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.App/containerApps/containerapp000003?api-version=2023-05-02-preview response: body: string: ''