az vm create --image --specialized seems broken
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
### 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//resourceGroups//providers/Microsoft.Compute/galleries//images//versions/`.
### Related command
`az vm create --specialized --image /subscriptions//resourceGroups//providers/Microsoft.Compute/galleries//images//versions/`
### Errors
If stdin is open, `az vm create` prompts with `Admin Password:` from [_prompt_for_password()](https://github.com/Azure/azure-cli/blob/f443ab1c1056f3530a59ba9d1a0e56d1f4bea472/src/azure-cli/azure/cli/command_modules/vm/_validators.py#L1160). 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 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?
Contributor guide
Assessment
This issue has not been assessed yet.