Azure / azure-cli

Azure Command-Line Interface
MIT License
4.01k stars 2.99k forks source link

Azure-CLI - Creating an NVA VM from a VHD in Container #27005

Closed aravind365 closed 1 year ago

aravind365 commented 1 year ago

Describe the bug

i have a VHD for an NVA in a page blob container in my storage account. I'm unable to work out how to create the VM using Azure CLI because. The issue is that the --source option isn't working and i couldn't find any resource online on ms or anywhere else. Appreciate any guidance. Many thanks !

Related command

PS /home/user> az vm create --name MYORG-AZURE-SZ1 -g AS_RG --accept-term --size $vmsize --tags $tags --zone 1 --admin-username cpeadmin --authentication-type ssh --generate-ssh-keys --accelerated-networking false --nic-delete-option Detach --nics AZURE-NVA-CPE-1-MGT-IF, AZURE-NVA-CPE-1-WAN-IF, AZURE-NVA-CPE-1-LAN-IF --subnet AZURE-NVA-MGT-SUBNET --os-type Linux --image "/subscriptions/****/resourceGroups/ng-resource-group/providers/Microsoft.Compute/images/vos212-B"

invalid usage for storage profile: create managed OS disk from custom image: not applicable: --os-type PS /home/user> az vm create --name MYORG-AZURE-SZ1 -g AS_RG --accept-term --size $vmsize --tags $tags --zone 1 --admin-username cpeadmin --authentication-type ssh --generate-ssh-keys --accelerated-networking false --nic-delete-option Detach --nics AZURE-NVA-CPE-1-MGT-IF, AZURE-NVA-CPE-1-WAN-IF, AZURE-NVA-CPE-1-LAN-IF --subnet AZURE-NVA-MGT-SUBNET --os-type Linux --image $image invalid usage for storage profile: create unmanaged OS disk created from generalized VHD: missing: --use-unmanaged-disk PS /home/user>

Errors

invalid usage for storage profile: create managed OS disk from custom image: not applicable: --os-type

profile: create unmanaged OS disk created from generalized VHD: missing: --use-unmanaged-disk PS /home/aravindh>

Issue script & Debug output

NA

Expected behavior

VM creation from CLI

Environment Summary

Az Cloud Shell

Additional context

No response

yonzhan commented 1 year ago

Thank you for opening this issue, we will look into it.

zhoxing-ms commented 1 year ago

invalid usage for storage profile: create managed OS disk from custom image: not applicable: --os-type

Please do not specify the --os-type when creating managed OS disk from custom image,

invalid usage for storage profile: create unmanaged OS disk created from generalized VHD: missing: --use-unmanaged-disk

You need to specify the parameter --use-unmanaged-disk when creating unmanaged OS disk created from generalized VHD

aravind365 commented 1 year ago

Hello Xing,

Thank you for your reply ! But it’s not working unfortunately.

--use-unmanaged-disk https://***.blob.core.windows.net/***.vhd unrecognized arguments: https://***.blob.core.windows.net/***.vhd

I also tried the subscription urn instead of the URL for the VHD.

--use-unmanaged-disk /subscriptions/*/resourceGroups/*-resource-group/providers/Microsoft.Compute/images/os212-B unrecognized arguments: /subscriptions//resourceGroups/**-resource-group/providers/Microsoft.Compute/images/os212-B

Should I be using one of these options instead ?

@.***

Example on az vm unmanaged-disk | Microsoft Learnhttps://learn.microsoft.com/en-us/cli/azure/vm/unmanaged-disk?view=azure-cli-latest#az-vm-unmanaged-disk-attach below –

az vm unmanaged-disk attach -g MyResourceGroup --vm-name MyVm --name MyDataDisk \ --vhd-uri https://mystorage.blob.core.windows.net/vhds/d1.vhd

Just for comparing, I looked at the CLI output for a VM (NVA) that was created using Azure portal GUI. I has ‘managed disk’ as per below. I’m totally at a loss as to how to proceed with this. Would really appreciate if you could evaluate and advise at the earliest.

"osDisk": { "caching": "ReadWrite", "createOption": "FromImage", "deleteOption": "Detach", "diffDiskSettings": null, "diskSizeGb": 80, "encryptionSettings": null, "image": null, "managedDisk": { "diskEncryptionSet": null, "id": "/subscriptions/**/resourceGroups/AS_RG/providers/Microsoft.Compute/disks/AS-CPE-1_disk1_d2ae5507163e435aa0a0c2e00f479ec1", "resourceGroup": "AS_RG", "securityProfile": null, "storageAccountType": "StandardSSD_LRS" }, "name": "AS-CPE-1_disk1_d2ae5507163e435aa0a0c2e00f479ec1", "osType": "Linux", "vhd": null, "writeAcceleratorEnabled": null }

--

zhoxing-ms commented 1 year ago

Thank you for your reply ! But it’s not working unfortunately.

@aravind365 May I ask what was the error message after trying the above methods? Could you please send the debug log (add --debug parameter) to my email?

aravind365 commented 1 year ago

I have got it working with your suggested option of using unmanaged disk ! Many thanks for your help !

Could you also possibly advise on a couple of other questions I've got please ?

1> What option would i use for a marketplace image NVA instead of the VHD stored in my 'Images' section on Azure ? 2> To automate full deployment of an NVA (all objects like NICs, PIPs, Subnets, VNETs, RGs, UDRs etc), which automation method is recommended ?

Thanks again !

aravind365 commented 1 year ago

i've learnt az cli. all good, thanks for your help.