Skip to content
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

{containerapp} add --enable-wordload-profiles helps and add preview tag #6698

Merged
merged 4 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions src/containerapp/azext_containerapp/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = """
Expand Down
8 changes: 4 additions & 4 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down Expand Up @@ -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.')
Expand Down
6 changes: 3 additions & 3 deletions src/containerapp/azext_containerapp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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():
Expand All @@ -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(),
Expand Down Expand Up @@ -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")
4 changes: 2 additions & 2 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: ''
Expand Down