Skip to content

Commit

Permalink
Fix create containerapp/containerappjob with msi issue (Azure#7970)
Browse files Browse the repository at this point in the history
  • Loading branch information
njuCZ authored Sep 13, 2024
1 parent 13bd9c7 commit 63339cb
Show file tree
Hide file tree
Showing 6 changed files with 11,713 additions and 8,184 deletions.
2 changes: 2 additions & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Release History
===============
upcoming
++++++
* 'az containerapp create': Fix container app create with registry msi
* 'az containerapp job create': Fix container app job create with registry msi

1.0.0b1
++++++
Expand Down
20 changes: 16 additions & 4 deletions src/containerapp/azext_containerapp/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,13 +749,25 @@ def is_registry_msi_system_environment(identity):

def env_has_managed_identity(cmd, resource_group_name, env_name, identity):
identity = identity.lower()
# caller should handle exception
managed_env_info = ManagedEnvironmentPreviewClient.show(cmd=cmd, resource_group_name=resource_group_name, name=env_name)
if is_registry_msi_system(identity) and managed_env_info["identity"]["type"].__contains__("SystemAssigned"):

try:
managed_env_info = ManagedEnvironmentPreviewClient.show(cmd=cmd, resource_group_name=resource_group_name, name=env_name)
except Exception as e:
handle_raw_exception(e)

if safe_get(managed_env_info, "identity") is None:
return False

identityType = safe_get(managed_env_info, "identity", "type")
if is_registry_msi_system(identity) and identityType and identityType.__contains__("SystemAssigned"):
return True

userAssignedIdentities = safe_get(managed_env_info, "identity", "userAssignedIdentities")
if userAssignedIdentities is None:
return False

result = False
for msi in managed_env_info["identity"]["userAssignedIdentities"]:
for msi in userAssignedIdentities:
if msi.lower() == identity:
result = True
break
Expand Down
Loading

0 comments on commit 63339cb

Please sign in to comment.