How can I get the URL of a captured VM Image stored in Azure Resource Manager?

浪子不回头ぞ 提交于 2019-12-24 07:19:45

问题


I am trying to create a new VM in Azure RM based on the sysprepped capture of an existing VM installation. That is:

$urlOfCapturedImage = <I cannot find this>

...

$vm = Set-AzureRmVMOSDisk -VM $vm -Name $osDiskName -VhdUri $newOsDiskUri `
        -CreateOption fromImage -SourceImageUri $urlOfCapturedImage -Windows

New-AzureRmVM -ResourceGroupName $resourceGroupName -Location $location -VM $vm

My current problem is finding the correct URL for the stored VM image, since it doesn't appear to be stored as a VHD blob in my storage account. Instead, I find it in the Images category, with the following, limited information:

I have tried using the following URL/URIs, but none of them work:

https://<storage-account-name>.blob.core.windows.net/system/Microsoft.Compute/Images/jira-7-sysprep-20170724133831.vhd

/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Compute/images/jira-7-sysprep-20170724133831

Does anyone know how to get the proper URL for my VM image? Or could it simply be that I am using the wrong method altogether?


回答1:


Does anyone know how to get the proper URL for my VM image?

For a Azure VM image, the VHD is managed by Azure, you could not get the URL.

Your command is used for create VM from storage account. If you want to create VM from image, you could use the following command to create a VM from custom image.

$image = Get-AzureRmImage `
    -ImageName myImage `
    -ResourceGroupName myResourceGroupImages

# Here is where we specify that we want to create the VM from and image and provide the image ID
$vmConfig = Set-AzureRmVMSourceImage -VM $vmConfig -Id $image.Id

$vmConfig = Add-AzureRmVMNetworkInterface -VM $vmConfig -Id $nic.Id

New-AzureRmVM `
    -ResourceGroupName myResourceGroupFromImage `
    -Location EastUS `
    -VM $vmConfig

More information about this please refer to this link.



来源:https://stackoverflow.com/questions/45297321/how-can-i-get-the-url-of-a-captured-vm-image-stored-in-azure-resource-manager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!