Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Friday, June 1, 2018 12:35 PM
Error while ARM template deployment. , {error={code=InvalidParameter, target=osDisk, message=Cannot specify user image overrides for a disk already defined in the specified image reference.}}, Template output evaluation skipped: at least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.
All replies (18)
Friday, June 1, 2018 6:45 PM
looks like have a set OSdisk name that is conflicting with another disk that is already in your resource group.
Can you share your arm template?
Monday, June 11, 2018 10:34 PM
Any update on this?
Friday, June 22, 2018 6:19 PM
I'm stuck with the same error,
Cannot specify user image overrides for a disk already defined in the specified image reference.
│ Reason : ComputeCloudException
│ hResult : -2146233088
in PowerShell with latest (today) AzureRm 6.3.0
I'm trying to mount an existing system disk, VHD, unmanaged, generalized, by converting it to Managed Disk, and mounting the MD directly in the VM.
$diskconfig = New-AzureRMDiskConfig -AccountType $SAT -Location $Location -CreateOption "Import" -SourceUri $SourceDiskInTempURL -oSType $OsDiskType -DiskSizeGB $SystemDiskSizeinGB
$mdisk = New-AzureRMDisk -Disk $diskconfig -ResourceGroupName $ResourceGroupname -DiskName "DiskTesting"
$VmConfig = Set-AzureRMVMOsDisk -vm $VmConfig -Name "DiskTesting" -ManagedDiskId $mdisk.id -CreateOption "FromImage" @paramsOnlyOSSwitch
Friday, June 22, 2018 7:56 PM
Juan, have you checked the following:
/en-us/azure/virtual-machines/windows/create-vm-specialized#create-a-managed-disk-from-the-vhd
Saturday, June 23, 2018 8:05 AM
Yes, I tried it (and some variations).
With the code based on it, Option2 from the stated doc,
$diskconfig = New-AzureRMDiskConfig -AccountType $SAT -Location $Location `
-CreateOption "Import" -SourceUri $SourceDiskInTempURL
$mdisk = New-AzureRMDisk -Disk $diskconfig -ResourceGroupName $ResourceGroupname -DiskName "DiskTesting"
$VmConfig = Set-AzureRMVMOsDisk -vm $VmConfig -Name "DiskTesting" -ManagedDiskId $mdisk.id -StorageAccountType $SAT `
-DiskSizeInGB $SystemDiskSizeinGB -CreateOption "Attach" @paramsOnlyOSSwitch
It takes 20 minutes, and it generates a useless VM.
You get an error (which seems to be a warning, as the VM is created) :
VM 'VM_ComputerW0' has not reported status for VM agent or extensions. Please verify the VM has a running VM agent, and can establish outbound connections to Azure storage
Probably because nobody called Set-AzureRMVMOperatingSystem. Then there's no Agent installed, and no credentials to login !!
Adding the missing line
$VmConfig = $VmConfig | Set-AzureRmVMOperatingSystem @paramsforOS -ComputerName $ComputerName -Credential $Credential ## -WarningAction "SilentlyContinue"
You get immediately an error :
ErrorMessage: Parameter 'osProfile' is not allowed.
I'm stuck here, testing lots of combinations... without luck.
Has anyone really tested this ? (6.3.0)
jc
Monday, June 25, 2018 12:27 PM
Same issue with Scale Sets.
Monday, June 25, 2018 4:24 PM
Are you both taking a snapshot of the disk or running the generalization process then deleting the VM and keeping the disks?
Monday, June 25, 2018 5:15 PM
I have a generalized VHD in a Storage Account, (BTW, how to know if a VHD was properly generalized ?)
Then tried
a) Converting it to Managed Disk and then mounting (would be my favorite) (Error given above)
b) adding the VHD directly in New-AzureRMDiskConfig -CreateOption "Import" -SourceURI $TheSourceURI . Works, but disk stays unmanaged.
c) Adding it to an Image and using it in the VMConfig. Failed with "Cannot specify user image overrides for a disk already defined in the specified image reference."
d) Snapshot or reusing converted disks not tried, I'd like to keep it as simple as possible,
I've managed to make it work with VMSS, as the cmdlets seem newer and they enforce using Managed Disks. In this case, the VHD is included in an Image, and Image.ID used then in OS Disk. I'll try to extrapolate this to the VM case.
Monday, June 25, 2018 6:04 PM
It looks like the issue is because the disk is a standalone. I am not finding any commands that allow conversion to managed disk from an unmanaged disk when not attached to a VM.
For example we have the following:
/en-us/azure/virtual-machines/windows/convert-unmanaged-to-managed-disks
ConvertTo-AzureRmVMManagedDisk -ResourceGroupName $rgName -VMName $vmName
So to get this to work, it seems you will need to have the disk attached to a VM, migrate to managed disk, delete the VM then you can deploy to a new VM as a managed disk.
Or if you have existing unmanaged disks VMs you can run the command and once they convert you can delete the old disks.
Monday, June 25, 2018 6:11 PM
Afaik, New-AzureRMDisk using a New-AzureRMDiskConfig can create a Managed Disk from a VHD, with no VM involved yet...
I'm already using ConvertTo-AzureRmVMManagedDisk as a workaround, but it does not fit very well in my process (looping thru many disks which could or could not be MDs), and then you cannot rename the Managed Disk names it assigns.
Monday, June 25, 2018 11:32 PM
So I think I got it to work. I did this to create the disk:
$config = New-AzureRmDiskConfig -OsType Windows -Location 'Central US' -CreateOption Import -SourceUri https://micahunmanageddisk759.blob.core.windows.net/vhds/MicahUnmanaged20180625091753.vhd
New-AzureRmDisk -ResourceGroupName MicahUnmanagedDisk -DiskName ManagedTest -Disk $config
Then from there you should be able to follow the standard creating from existing managed disk. Can you give that a try?
Tuesday, June 26, 2018 2:09 PM
I think I already tried that combination (and failed), but thanks for your effort, I'm checking it again following your code.
My simplest (reduced) repro :
$OSAstext = "Windows"; $OSAsSwitch = @{"Windows"=$True"}; $Location ="WestEurope"
$SourceDiskInTempUrl = "https://tempwejc112.blob.core.windows.net/tempinwe/disks/WindowsOS.vhd"
$paramsForOS = @{"Windows"=$true; "WinRMHTTP"=$True; "ProvisionVMAgent" = $true; "EnableAutoUpdate"=$false }
$Computername, $ResourceGroupName,$Credential have also valid values.
#
$DiskConfig = New-AzureRMDiskConfig -OSType $OSAsText -Location $Location -CreateOption "Import" -SourceURI $SourceDiskInTempURL
$MDisk = New-AzureRMDisk -ResourceGroupName $ResourceGroupname -DiskName "MDISKKK" -Disk $DiskConfig
$VmConfig = Set-AzureRMVMOsDisk -VM $VmConfig -ManagedDiskId $mdisk.id -CreateOption "FromImage" @OSAsSwitch
$VmConfig = $VmConfig | Set-AzureRmVMOperatingSystem @paramsforOS -ComputerName $ComputerName -Credential $Credential
When creating the VM with this VMCONFIG,
*** New-AzureRMVM failed : Cannot specify user image overrides for a disk already defined in the specified image reference.***
Probably has something to do with the TWO -CreateOption values in the 1st and 3rd cmdlets. I'm trying combinations of IMPORT, COPY, FROMIMAGE, ATTACH, or none at all, but that's 25 combinations... I'd prefer to see the documentation instead. By the way, this parameter is a STRING and not an enumeration, and depending on the values the other parameters also change.
BTW, the Managed Disk is created with no problem. It's attaching it to the VM which fails.
Any help is welcome.
Tuesday, June 26, 2018 7:41 PM
Here is the script I used that successful created the VM:
$subscriptionId = 'XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXf'
$resourceGroupName ='MicahMDTest1'
$virtualNetworkName = 'MicahMDVnet1'
$virtualMachineName = 'MivahMDTest'
$virtualMachineSize = 'Standard_DS3'
$diskName = 'MicahMD1'
$location = 'Central US'
$osType = 'Windows'
$sourceUri = 'https://micahunmanageddisk759.blob.core.windows.net/vhds/MicahUnmanaged20180625091753.vhd'
Select-AzureRmSubscription -SubscriptionId $SubscriptionId
$diskconfig = New-AzureRmDiskConfig -OsType $osType -Location $location -CreateOption Import -SourceUri $sourceUri
$disk = New-AzureRmDisk -ResourceGroupName $resourceGroupName -DiskName $diskName -Disk $diskconfig
#Initialize virtual machine configuration
$VirtualMachine = New-AzureRmVMConfig -VMName $virtualMachineName -VMSize $virtualMachineSize
#Use the Managed Disk Resource Id to attach it to the virtual machine. Please change the OS type to linux if OS disk has linux OS
$VirtualMachine = Set-AzureRmVMOSDisk -VM $VirtualMachine -ManagedDiskId $disk.Id -CreateOption Attach -Windows
#Create a public IP for the VM
$publicIp = New-AzureRmPublicIpAddress -Name ($VirtualMachineName.ToLower()+'_ip') -ResourceGroupName $resourceGroupName -Location $location -AllocationMethod Dynamic
#Get the virtual network where virtual machine will be hosted
$vnet = Get-AzureRmVirtualNetwork -Name $virtualNetworkName -ResourceGroupName $resourceGroupName
# Create NIC in the first subnet of the virtual network
$nic = New-AzureRmNetworkInterface -Name ($VirtualMachineName.ToLower()+'_nic') -ResourceGroupName $resourceGroupName -Location $location -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $publicIp.Id
$VirtualMachine = Add-AzureRmVMNetworkInterface -VM $VirtualMachine -Id $nic.Id
#Create the virtual machine with Managed Disk
New-AzureRmVM -VM $VirtualMachine -ResourceGroupName $resourceGroupName -Location $location
Note that the Source URI I used is taken from when I went to the portal, selected the managed disk and copied the Source URL
Tuesday, June 26, 2018 9:08 PM
Getting better... but not completely.
I've cloned your demo code, Import+Attach, in my function. The VMs is effectively created with the managed disk...
... but now we have a VM based on a generalized VHD, without a known username/password, no way to RDP in, and no agents. Which is completely logic as they were not provided in the code.
The creation as it is (New-AzureRMVM) gives this warning, after a long time (the VM is effectively created) :
* Long running operation failed with status 'Failed'. Additional Info:'VM 'VM_ComputerTest' has not reported status for VM agent or extensions. Please verify the VM has a running VM agent, and can establish outbound connections to Azure storage.'*
If I add the missing line at the end (which works in other cases, when the VM is created from non-managed disks),
$VmConfig = $VmConfig | Set-AzureRmVMOperatingSystem @paramsforOS -ComputerName $ComputerName -Credential $Credential
I get this error (immediately, parameter validation does not even allow to try to create the VM):
* New-AzureRMVM failed : Parameter 'osProfile' is not allowed.*
My hypothesis: Could it be that somewhere in the process the original disk is de-generalized, or marked as such, which then does not allow to specify the OS parameters (osProfile) ?
Thanks again,
jc
Wednesday, June 27, 2018 12:41 AM
What about if you took a managed image of the VHD after generalizing then building a new VM?
/en-us/azure/virtual-machines/windows/upload-generalized-managed
Wednesday, June 27, 2018 6:03 AM
Yes, I already considered that (Image), and began to try it. Also with a Snapshot.
I'm sure it should work, but have spent so much time with different options, -CreateOption parameters, different -VHDURI, -SourceURI and so many interdependent parameters, and reading lots of incoherent blogs and books, that decided that someone would have an already full working script...
BTW, I found in a blog , quoting,
# Yes, Azure does not support reset username and password for an existing OS disk.
# https://stackoverflow.com/questions/48911865/creating-vm-from-managed-data-disk
Is that officially true ?
Wednesday, June 27, 2018 9:38 AM
Finally got it working.
The solution is only documented in
at the end, in the "Syntax Difference" section.
It would be nice to see it inside / ...
Thanks,
jc
Wednesday, June 27, 2018 3:35 PM
Hi Juan,
Thanks for the update! Glad to hear you finally got it working :) Was not an easy task to say the least....
I completely agree we should document this. Would you be able to leave the feedback on this doc:
if you scroll to the bottom you will see an option to provide doc feedback. That way we can triage it and get it assigned to a content author to review and get some doc updates :)