2017-07-25 13 views
0

我正嘗試在基於sysprepped捕獲的現有VM安裝的Azure RM中創建一個新的虛擬機。那就是:如何獲取存儲在Azure資源管理器中的捕獲的VM映像的URL?

$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 

我現在的問題是找到用於存儲虛擬機圖像顯示爲正確的網址,因爲它似乎並沒有被存儲在我的存儲帳戶VHD團塊。相反,我覺得在圖片類別,具有以下,有限的信息:

enter image description here

我已經使用下面的URL/URI的嘗試,但他們沒有工作:

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 

有誰知道如何爲我的VM映像獲取正確的URL?或者僅僅是因爲我完全使用了錯誤的方法?

回答

1

有誰知道如何爲我的VM映像獲取正確的URL?

對於Azure VM映像,VHD由Azure管理,您無法獲取URL。

您的命令用於從存儲帳戶創建虛擬機。如果您想從映像創建虛擬機,可以使用以下命令從自定義映像創建虛擬機。

$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 

更多相關信息請參考此link

+0

這正是我所期待的。謝謝! –

相關問題