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.
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.
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 withAdmin 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: https://github.com/Azure/azure-cli/blob/f443ab1c1056f3530a59ba9d1a0e56d1f4bea472/src/azure-cli/azure/cli/command_modules/vm/_validators.py#L1100 (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 https://github.com/Azure/azure-cli/blob/f443ab1c1056f3530a59ba9d1a0e56d1f4bea472/src/azure-cli/azure/cli/command_modules/vm/_validators.py#L393.
This is based on the detection of the image argument at https://github.com/Azure/azure-cli/blob/f443ab1c1056f3530a59ba9d1a0e56d1f4bea472/src/azure-cli/azure/cli/command_modules/vm/_validators.py#L246
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 withParameter '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?