Skip to content

Commit 9074533

Browse files
committed
Update code
1 parent 55f978a commit 9074533

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/aem/azext_aem/custom.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,26 @@ def _enable_new(self):
151151
logger.info("VM has user assigned identity, enabling user and system assigned")
152152
new_identity = IDENTITY_SYSTEM_USER_ASSIGNED
153153

154+
if vm_identity.get('type') == IDENTITY_USER_ASSIGNED or \
155+
vm_identity.get('type') == IDENTITY_SYSTEM_USER_ASSIGNED:
156+
user_assigned = [x for x in vm_identity.get('userAssignedIdentities', {}).keys()]
157+
else:
158+
user_assigned = []
159+
154160
if new_identity is not None:
155161
from azure.cli.command_modules.vm.aaz.latest.vm import Patch as VMPatch
156162
command_args = {
157163
'resource_group': self._resource_group,
158164
'vm_name': self._vm['name'],
159165
}
160166
if new_identity == IDENTITY_SYSTEM_ASSIGNED or new_identity == IDENTITY_SYSTEM_USER_ASSIGNED:
161-
command_args['mi_system_assigned'] = True
167+
command_args['mi_system_assigned'] = 'True'
168+
if new_identity == IDENTITY_SYSTEM_USER_ASSIGNED:
169+
command_args['mi_user_assigned'] = user_assigned
170+
print(command_args)
162171

163172
poller = VMPatch(cli_ctx=self._cmd.cli_ctx)(command_args=command_args)
164-
self._vm = LongRunningOperation(self._cmd.cli_ctx)(poller).result()
173+
self._vm = LongRunningOperation(self._cmd.cli_ctx)(poller)
165174

166175
scopes = set()
167176
end_index = 5 # Scope is set to resource group

0 commit comments

Comments
 (0)