Skip to content

az vm create --image --specialized seems broken #28428

Description

@maruel

Describe the bug

az vm create --specialized consistently prompts for a password when using an image via a full resource path in the form /subscriptions/<guid>/resourceGroups/<resource_group>/providers/Microsoft.Compute/galleries/<gallery>/images/<name>/versions/<version>.

Related command

az vm create --specialized --image /subscriptions/<guid>/resourceGroups/<resource_group>/providers/Microsoft.Compute/galleries/<gallery>/images/<name>/versions/<version>

Errors

If stdin is open, az vm create prompts with Admin Password: from _prompt_for_password(). When stdin is closed, it prompts this error message:
ERROR: Please specify password in non-interactive mode.

Issue script & Debug output

The logic to ask for a password is shortcut by the check at:

if namespace.storage_profile in [StorageProfile.ManagedSpecializedOSDisk,

(current dev branch commit)
which skips the password prompt not if the VM is specialized but if the storage_profile is one of ManagedSpecializedOSDisk or SASpecializedOSDisk.

The storage_profile when --image is provided is determined at

elif namespace.image and not getattr(namespace, 'attach_os_disk', None):
.

This is based on the detection of the image argument at

if is_valid_resource_id(namespace.image):

The determination for a valid resource id is https://github.com/Azure/msrestazure-for-python/blob/HEAD/msrestazure/tools.py#L185. The problem is that

Expected behavior

Using --specialized should completely disable the password prompt. Otherwise, the VM creation process fails with Parameter 'osProfile' is not allowed. (which is correct).

Using an image_id with a specialized image should work.

storage_profile is set to StorageProfile.ManagedSpecializedOSDisk when --attach-os-disk is provided. I had confirmed this to work when creating a disk from a snapshot.

Environment Summary

macOS, az CLI v2.57.0

Additional context

Did this ever work?

Metadata

Metadata

Labels

Azure CLI TeamThe command of the issue is owned by Azure CLI teamComputeaz vm/vmss/image/disk/snapshotact-observability-squadquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions