Reputation: 5126
I am trying to publish my product on Azure marketplaces.
I am using windows 2012 R2 Datacenter that I use to create a VM from portal.azure.com
. I followed steps of running a sysprep, generalizing it and then creating containers.
After that when we run save-azurermvmimage
to capture image, I get the capture action is only supported on a virtual machine with blob based disks. please use the image resource apis to create an image from a managed virtual machine
So I am not able to get the image url in container. Is there anything I am doing wrong?
Please guide!
Upvotes: 3
Views: 1807
Reputation: 71
In Atihska steps, After Sysprep , machine will be shutdown and status will shown as stopped but not stopped (deallocated). For deallocation, you need to run below powershell commands.
Stop-AzureRMVM -ResourceGroupName ResourceGroup -Name VMName
Set-AzureRMVM -ResourceGroupName ResourceGroup -Name VMName -Generalized
Upvotes: 0
Reputation: 5126
@Jason Ye: I was able to solve my problem and publish. I stopped using powershell and used only azure portal to do all the steps. The MS documentation provided is fragmented and new, old versions are combined even though they are deprecated. They are written in a way assuming that the reader has already experienced doing things.
So after lot of work done, I eventually came up with these steps:
Upvotes: 1
Reputation: 13974
Managed disk is different from unmanaged disk. We can use Powershell to create a managed image, but we can't find this new image in our storage account, managed disk manage by Azure, we can't manage it directly.
To create a managed image of a VM, we can follow those steps:
run sysprep to generalize the windows VM.(This process deletes the original virtual machine after it's captured.Prior to capturing an image of an Azure virtual machine, it is recommended the target virtual machine be backed up. )
$vmName = "myVM"
$rgName = "myResourceGroup"
$location = "EastUS"
$imageName = "myImage"
Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName -Force
Set-AzureRmVm -ResourceGroupName $rgName -Name $vmName -Generalized
$vm = Get-AzureRmVM -Name $vmName -ResourceGroupName $rgName
$image = New-AzureRmImageConfig -Location $location -SourceVirtualMachineId $vm.ID
New-AzureRmImage -Image $image -ImageName $imageName -ResourceGroupName $rgName
After it completed, we can find this image here:
More information about create a managed image, please refer to this link.
By the way, we should use Azure PowerShell 3.7.0 or later.
PS C:\Users> Get-Module -ListAvailable -Name Azure -Refresh
Directory: C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 3.7.0 Azure {Get-AzureAutomationCertificate, Get-AzureAutomationConnec...
Upvotes: 7