Skip to content
Open
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
27 changes: 3 additions & 24 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,12 +845,7 @@ def create_snapshot(cmd, resource_group_name, snapshot_name, location=None, size
def show_vm_identity(cmd, resource_group_name, vm_name):
vm = get_vm_by_aaz(cmd, resource_group_name, vm_name)

identity = vm.get("identity", {}) if vm else None

if identity and not identity.get('userAssignedIdentities'):
identity['userAssignedIdentities'] = None

return identity or None
return vm.get("identity") if vm else None
Comment on lines 845 to +848
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

show_vm_identity no longer normalizes the identity payload: it can now return an empty dict (instead of None) when the VM has no identity, and it can omit/leave an empty userAssignedIdentities instead of returning null. This is observable in az vm identity show and breaks existing test expectations (e.g., checks for userAssignedIdentities == None and is_empty() for no identity). Please restore the previous output shape: return None when identity is missing/empty, and when identity exists but has no user-assigned identities, ensure userAssignedIdentities is present and set to None.

Copilot uses AI. Check for mistakes.


def show_vmss_identity(cmd, resource_group_name, vm_name):
Expand Down Expand Up @@ -1773,13 +1768,7 @@ def _output(self, *args, **kwargs):
if has_value(resource.type):
resource.type = AAZUndefined

result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
if result.get('osProfile', {}).get('secrets', []):
for secret in result['osProfile']['secrets']:
for cert in secret.get('vaultCertificates', []):
if not cert.get('certificateStore'):
cert['certificateStore'] = None
return result
return self.deserialize_output(self.ctx.vars.instance, client_flatten=True)

vm = LongRunningOperation(cmd.cli_ctx)(
SetVM(cli_ctx=cmd.cli_ctx)(command_args=vm))
Expand Down Expand Up @@ -2625,10 +2614,7 @@ def _remove_identities_by_aaz(cmd, resource_group_name, name, identities, getter

result = LongRunningOperation(cmd.cli_ctx)(setter(resource_group_name, name, resource))

if not result:
return None

return result.get('identity') or None
return result.get('identity') if result else None


def remove_vm_identity(cmd, resource_group_name, vm_name, identities=None):
Expand Down Expand Up @@ -3351,13 +3337,6 @@ def add_vm_secret(cmd, resource_group_name, vm_name, keyvault, certificate, cert

def list_vm_secrets(cmd, resource_group_name, vm_name):
vm = get_vm_by_aaz(cmd, resource_group_name, vm_name)

if vm.get('osProfile', {}).get('secrets', []):
for secret in vm['osProfile']['secrets']:
for cert in secret.get('vaultCertificates', []):
if not cert.get('certificateStore'):
cert['certificateStore'] = None

return vm.get('osProfile', {}).get('secrets', [])


Expand Down
11 changes: 1 addition & 10 deletions src/azure-cli/azure/cli/command_modules/vm/operations/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,7 @@ def _output(self, *args, **kwargs):
if has_value(resource.type):
resource.type = AAZUndefined

result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)

identity = result.get('identity')
if not identity:
return result

if not identity.get('userAssignedIdentities'):
identity['userAssignedIdentities'] = None

return result
return self.deserialize_output(self.ctx.vars.instance, client_flatten=True)

Comment on lines 196 to 200
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VMIdentityRemove._output previously ensured identity.userAssignedIdentities is serialized as null when empty/missing. Returning the raw deserialized output can change the CLI contract for identity removal (e.g., az vm identity remove output may omit userAssignedIdentities or return {}), which is inconsistent with other identity outputs that tests validate as None. Please keep the output normalization for identity.userAssignedIdentities (set to None when not present / empty) before returning the result.

Copilot uses AI. Check for mistakes.
class VirtualMachinesUpdate(_VMPatch.VirtualMachinesUpdate):
# Override to solve key conflict of _schema_on_200.resources.Element.properties.type when deserializing
Expand Down