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] Remove GA commands which exist in azure-cli version 2.62.0 and release 0.3.54 #7837

Merged
merged 9 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
5 changes: 5 additions & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ Release History
===============
upcoming
++++++

0.3.54
++++++
* 'az containerapp env create/update': Support `--public-network-access` to allow or block public network
* Update azure cli dependency version >= "2.62.0"
* Remove GA commands which exist in azure-cli version 2.62.0

0.3.53
++++++
Expand Down
1 change: 1 addition & 0 deletions src/containerapp/azext_containerapp/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def _polish_bad_errors(ex):
import json
try:
content = json.loads(ex.response.content)
detail = None
if 'message' in content:
detail = content['message']
elif 'Message' in content:
Expand Down
22 changes: 0 additions & 22 deletions src/containerapp/azext_containerapp/_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,28 +310,6 @@ def list(cls, cmd, resource_group_name, dapr_component_name, environment_name):
return policy_list


class SubscriptionPreviewClient():
api_version = PREVIEW_API_VERSION

@classmethod
def show_custom_domain_verification_id(cls, cmd):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
sub_id = get_subscription_id(cmd.cli_ctx)
request_url = f"{management_hostname}subscriptions/{sub_id}/providers/Microsoft.App/getCustomDomainVerificationId?api-version={cls.api_version}"

r = send_raw_request(cmd.cli_ctx, "POST", request_url)
return r.json()

@classmethod
def list_usages(cls, cmd, location):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
sub_id = get_subscription_id(cmd.cli_ctx)
request_url = f"{management_hostname}subscriptions/{sub_id}/providers/Microsoft.App/locations/{location}/usages?api-version={cls.api_version}"

r = send_raw_request(cmd.cli_ctx, "GET", request_url)
return r.json()


class StoragePreviewClient(StorageClient):
api_version = PREVIEW_API_VERSION

Expand Down
28 changes: 0 additions & 28 deletions src/containerapp/azext_containerapp/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@
short-summary: Manage Azure Container Apps.
"""

helps['containerapp list-usages'] = """
type: command
short-summary: List usages of subscription level quotas in specific region.
examples:
- name: List usages of quotas in specific region.
text: |
az containerapp list-usages -l eastus
"""

helps['containerapp env list-usages'] = """
type: command
short-summary: List usages of quotas for specific managed environment.
examples:
- name: List usages of quotas for specific managed environment.
text: |
az containerapp env list-usages -n MyEnv -g MyResourceGroup
"""

helps['containerapp env dapr-component resiliency'] = """
type: group
Expand Down Expand Up @@ -177,17 +160,6 @@
az containerapp up -n my-containerapp --image myregistry.azurecr.io/myImage:myTag --environment MyConnectedEnvironmentId
"""

helps['containerapp show-custom-domain-verification-id'] = """
type: command
short-summary: Show the verification id for binding app or environment custom domains
examples:
- name: Get the verification id, which needs to be added as a TXT record for app custom domain to verify domain ownership
text: |
az containerapp show-custom-domain-verification-id
- name: Get the verification id, which needs to be added as a TXT record for custom environment DNS suffix to verify domain ownership
text: |
az containerapp show-custom-domain-verification-id
"""

helps['containerapp replica count'] = """
type: command
Expand Down
9 changes: 0 additions & 9 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,6 @@ def load_arguments(self, _):
c.argument('service_principal_client_secret', help='The service principal client secret. Used by Github Actions to authenticate with Azure.', options_list=["--service-principal-client-secret", "--sp-sec"])
c.argument('service_principal_tenant_id', help='The service principal tenant ID. Used by Github Actions to authenticate with Azure.', options_list=["--service-principal-tenant-id", "--sp-tid"])

with self.argument_context('containerapp auth') as c:
# subgroup update
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)

with self.argument_context('containerapp env workload-profile set') as c:
c.argument('workload_profile_type', help="The type of workload profile to add or update. Run 'az containerapp env workload-profile list-supported -l <region>' to check the options for your region.")
c.argument('min_nodes', help="The minimum node count for the workload profile")
Expand Down Expand Up @@ -386,9 +380,6 @@ def load_arguments(self, _):
c.argument('resource_group_name', arg_type=resource_group_name_type, id_part=None)
c.argument('dotnet_component_type', options_list=['--type'], arg_type=get_enum_type(['AspireDashboard']), help="The type of DotNet component.")

with self.argument_context('containerapp env', arg_group='Peer Traffic Configuration') as c:
c.argument('p2p_encryption_enabled', arg_type=get_three_state_flag(), options_list=['--enable-peer-to-peer-encryption'], is_preview=True, help='Boolean indicating whether the peer-to-peer traffic encryption is enabled for the environment.')

with self.argument_context('containerapp sessionpool') as c:
c.argument('name', options_list=['--name', '-n'], help="The Session Pool name.")
c.argument('resource_group_name', arg_type=resource_group_name_type, id_part=None)
Expand Down
13 changes: 0 additions & 13 deletions src/containerapp/azext_containerapp/_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@ def transform_sensitive_values(response_json):
return response_json


def transform_usages_output(result):
table_result = []
for item in result["value"]:
value = {
"Name": item["name"]["value"],
"Usage": item["usage"],
"Limit": item["limit"]
}
table_result.append(value)

return table_result


def transform_telemetry_data_dog_values(response_json):
containerapp_env_def = response_json

Expand Down
2 changes: 1 addition & 1 deletion src/containerapp/azext_containerapp/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.53.0"
"azext.minCliCoreVersion": "2.62.0"
}
11 changes: 3 additions & 8 deletions src/containerapp/azext_containerapp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
# from msrestazure.tools import is_valid_resource_id, parse_resource_id
from azure.cli.command_modules.containerapp._transformers import (transform_containerapp_output, transform_containerapp_list_output)
from azext_containerapp._client_factory import ex_handler_factory
from ._transformers import (transform_usages_output,
transform_sensitive_values,
from ._transformers import (transform_sensitive_values,
transform_telemetry_data_dog_values,
transform_telemetry_app_insights_values,
transform_telemetry_otlp_values,
Expand All @@ -25,8 +24,6 @@ def load_command_table(self, args):
g.custom_command('update', 'update_containerapp', supports_no_wait=True, exception_handler=ex_handler_factory(), table_transformer=transform_containerapp_output, transform=transform_sensitive_values)
g.custom_command('delete', 'delete_containerapp', supports_no_wait=True, confirmation=True, exception_handler=ex_handler_factory())
g.custom_command('up', 'containerapp_up', supports_no_wait=False, exception_handler=ex_handler_factory())
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 @@ -39,7 +36,6 @@ def load_command_table(self, args):
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, is_preview=True)

with self.command_group('containerapp job') as g:
g.custom_show_command('show', 'show_containerappsjob')
Expand All @@ -49,10 +45,9 @@ def load_command_table(self, args):
g.custom_command('delete', 'delete_containerappsjob', supports_no_wait=True, confirmation=True, exception_handler=ex_handler_factory())

with self.command_group('containerapp env certificate') as g:
g.custom_command('create', 'create_managed_certificate', is_preview=True)
g.custom_command('upload', 'upload_certificate')
g.custom_command('list', 'list_certificates', is_preview=True)
g.custom_command('delete', 'delete_certificate', confirmation=True, exception_handler=ex_handler_factory(), is_preview=True)
g.custom_command('list', 'list_certificates')
g.custom_command('delete', 'delete_certificate', confirmation=True, exception_handler=ex_handler_factory())

with self.command_group('containerapp env dapr-component') as g:
g.custom_command('init', 'init_dapr_components', is_preview=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,12 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=line-too-long
# pylint: disable=line-too-long, useless-parent-delegation

from azure.cli.command_modules.containerapp.containerapp_auth_decorator import ContainerAppAuthDecorator
from azure.cli.command_modules.containerapp._utils import safe_set

from ._constants import BLOB_STORAGE_TOKEN_STORE_SECRET_SETTING_NAME
from azure.cli.core.azclierror import ArgumentUsageError


# decorator for preview auth show/update
class ContainerAppPreviewAuthDecorator(ContainerAppAuthDecorator):
def construct_payload(self):
super().construct_payload()
self.set_up_token_store()

def set_up_token_store(self):
if self.get_argument_token_store() is None:
return

if self.get_argument_token_store() is False:
safe_set(self.existing_auth, "login", "tokenStore", "enabled", value=False)
return

safe_set(self.existing_auth, "login", "tokenStore", "enabled", value=True)

if self.get_argument_sas_url_secret() is None and self.get_argument_sas_url_secret_name() is None:
raise ArgumentUsageError('Usage Error: only blob storage token store is supported. --sas-url-secret and --sas-url-secret-name should provide exactly one when token store is enabled')
if self.get_argument_sas_url_secret() is not None and self.get_argument_sas_url_secret_name() is not None:
raise ArgumentUsageError('Usage Error: --sas-url-secret and --sas-url-secret-name cannot both be set')

sas_url_setting_name = BLOB_STORAGE_TOKEN_STORE_SECRET_SETTING_NAME
if self.get_argument_sas_url_secret_name() is not None:
sas_url_setting_name = self.get_argument_sas_url_secret_name()
safe_set(self.existing_auth, "login", "tokenStore", "azureBlobStorage", "sasUrlSettingName", value=sas_url_setting_name)

def get_argument_token_store(self):
return self.get_param("token_store")

def get_argument_sas_url_secret(self):
return self.get_param("sas_url_secret")

def get_argument_sas_url_secret_name(self):
return self.get_param("sas_url_secret_name")

def get_argument_yes(self):
return self.get_param("yes")
35 changes: 0 additions & 35 deletions src/containerapp/azext_containerapp/containerapp_env_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ def validate_arguments(self):
if (not self.get_argument_certificate_file()) and (not self.get_argument_certificate_key_vault_url()):
raise ValidationError("Either --certificate-file or --certificate-akv-url should be set when --dns-suffix is set")

# validate mtls and p2p traffic encryption
if self.get_argument_p2p_encryption_enabled() is False and self.get_argument_mtls_enabled() is True:
raise ValidationError("Cannot use '--enable-mtls' with '--enable-peer-to-peer-encryption False'")

def set_up_public_network_access(self):
if self.get_argument_public_network_access():
safe_set(self.managed_env_def, "properties", "publicNetworkAccess",
Expand Down Expand Up @@ -161,16 +157,6 @@ def set_up_custom_domain_configuration(self):
}
self.managed_env_def["properties"]["customDomainConfiguration"] = custom_domain

def set_up_peer_to_peer_encryption(self):
is_p2p_encryption_enabled = self.get_argument_p2p_encryption_enabled()
is_mtls_enabled = self.get_argument_mtls_enabled()

if is_p2p_encryption_enabled is not None:
safe_set(self.managed_env_def, "properties", "peerTrafficConfiguration", "encryption", "enabled", value=is_p2p_encryption_enabled)

if is_mtls_enabled is not None:
safe_set(self.managed_env_def, "properties", "peerAuthentication", "mtls", "enabled", value=is_mtls_enabled)

def get_argument_enable_workload_profiles(self):
return self.get_param("enable_workload_profiles")

Expand All @@ -192,9 +178,6 @@ def get_argument_certificate_identity(self):
def get_argument_certificate_key_vault_url(self):
return self.get_param("certificate_key_vault_url")

def get_argument_p2p_encryption_enabled(self):
return self.get_param("p2p_encryption_enabled")

def get_argument_public_network_access(self):
return self.get_param("public_network_access")

Expand All @@ -207,14 +190,9 @@ def validate_arguments(self):
if self.get_argument_certificate_file() and self.get_argument_certificate_key_vault_url():
raise ValidationError("Cannot use certificate --certificate-file with --certificate-akv-url at the same time")

# validate mtls and p2p traffic encryption
if self.get_argument_p2p_encryption_enabled() is False and self.get_argument_mtls_enabled() is True:
raise ValidationError("Cannot use '--enable-mtls' with '--enable-peer-to-peer-encryption False'")

def construct_payload(self):
super().construct_payload()

self.set_up_peer_to_peer_encryption()
self.set_up_public_network_access()

def set_up_public_network_access(self):
Expand Down Expand Up @@ -262,16 +240,6 @@ def set_up_custom_domain_configuration(self):
safe_set(self.managed_env_def, "properties", "customDomainConfiguration", "certificateValue", value="")
safe_set(self.managed_env_def, "properties", "customDomainConfiguration", "certificatePassword", value="")

def set_up_peer_to_peer_encryption(self):
is_p2p_encryption_enabled = self.get_argument_p2p_encryption_enabled()
is_mtls_enabled = self.get_argument_mtls_enabled()

if is_p2p_encryption_enabled is not None:
safe_set(self.managed_env_def, "properties", "peerTrafficConfiguration", "encryption", "enabled", value=is_p2p_encryption_enabled)

if is_mtls_enabled is not None:
safe_set(self.managed_env_def, "properties", "peerAuthentication", "mtls", "enabled", value=is_mtls_enabled)

def get_argument_logs_dynamic_json_columns(self):
return self.get_param("logs_dynamic_json_columns")

Expand All @@ -281,8 +249,5 @@ def get_argument_certificate_identity(self):
def get_argument_certificate_key_vault_url(self):
return self.get_param("certificate_key_vault_url")

def get_argument_p2p_encryption_enabled(self):
return self.get_param("p2p_encryption_enabled")

def get_argument_public_network_access(self):
return self.get_param("public_network_access")
Loading
Loading