Skip to content

Commit 587055c

Browse files
[Containerapp] az containerapp sessionpool update: Fix updating registry credentials with --registry-username and --registry-password when existing registry credentials are empty (#8483)
* fix * fix issue: NoneType error * add history * update test * fix style: src/containerapp/azext_containerapp/_utils.py:109:37: E1123: Unexpected keyword argument 'resource' in method call (unexpected-keyword-arg) * remove unused function * add more guidance --------- Co-authored-by: xinyu pang <[email protected]>
1 parent 9489a90 commit 587055c

File tree

6 files changed

+52585
-3700
lines changed

6 files changed

+52585
-3700
lines changed

src/containerapp/HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Release History
44
===============
55
upcoming
66
++++++
7+
* 'az containerapp sessionpool update': Fix updating registry credentials with `--registry-username` and `--registry-password` when existing registry credentials are empty
78

89
1.1.0b2
910
++++++

src/containerapp/azext_containerapp/_utils.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,6 @@ def process_service(cmd, resource_list, service_name, arg_dict, subscription_id,
103103
raise ResourceNotFoundError("Service with the given name does not exist")
104104

105105

106-
def get_linker_client(cmd):
107-
resource = cmd.cli_ctx.cloud.endpoints.active_directory_resource_id
108-
profile = Profile(cli_ctx=cmd.cli_ctx)
109-
credential, subscription_id, _ = profile.get_login_credentials(
110-
subscription_id=get_subscription_id(cmd.cli_ctx), resource=resource)
111-
linker_client = ServiceLinkerManagementClient(credential)
112-
return linker_client
113-
114-
115106
def validate_binding_name(binding_name):
116107
pattern = r'^(?=.{1,60}$)[a-zA-Z0-9._]+$'
117108
return bool(re.match(pattern, binding_name))

src/containerapp/azext_containerapp/containerapp_sessionpool_decorator.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,14 +487,21 @@ def set_up_container(self, customer_container_template):
487487
return container_def
488488

489489
def set_up_registry_auth_configuration(self, secrets_def, customer_container_template):
490+
if self.has_registry_change():
491+
if safe_get(customer_container_template, "registryCredentials") is None:
492+
if self.get_argument_registry_server() is None or (self.get_argument_registry_user() is None or self.get_argument_registry_pass() is None):
493+
raise ValidationError("The existing registry credentials are empty. \n"
494+
"Please provide --registry-server, --registry-username, and --registry-password to update the registry credentials. \n"
495+
"If you want to use managed identity for registry, please use `az containerapp sessionpool create --registry-server myregistry.azurecr.io --registry-identity MyUserIdentityResourceId`.\n")
496+
safe_set(customer_container_template, "registryCredentials", value={})
490497
if self.get_argument_registry_server() is not None:
491498
safe_set(customer_container_template, "registryCredentials", "server", value=self.get_argument_registry_server())
492499
if self.get_argument_registry_user() is not None:
493500
safe_set(customer_container_template, "registryCredentials", "username", value=self.get_argument_registry_user())
494501
if secrets_def is None:
495502
secrets_def = []
496503
if self.get_argument_registry_pass() is not None:
497-
original_secrets = self.existing_pool_def["properties"]["secrets"]
504+
original_secrets = safe_get(self.existing_pool_def, "properties", "secrets", default=[])
498505
original_secrets_names = []
499506
for secret in original_secrets:
500507
original_secrets_names.append(secret["name"])

0 commit comments

Comments
 (0)