0
votes

I am creating a new VM using Azure RM from a copied image; the error is:

New-AzureRMVM : Source and destination storage accounts for disk osdisk are different. StatusCode: 409 ReasonPhrase: Conflict OperationID : 'c55f44a7-b46c-423c-aa52-6bb8a99391ee'

  • New-AzureRMVM -ResourceGroupName $resourceGroupName -Location $location -VM $vm
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    • CategoryInfo : CloseError: (:) [New-AzureRmVM], ComputeCloudException
    • FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand

what am I missing?

1
steps: 1. create storage account in AR subscription 2. copy custom vhd to this storage account 3. create VM using the VHD from step (2) fyi: source and dest are on different subscription/resourcegroupSBC

1 Answers

0
votes

Its in the error message, it not posible to deploy a vhd from a diffrent storage account when creating a VM.

You will have to copy the VHD over to the same storage account the VM will run out of before you start to deploy the VHD.

Copy past from here: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-upload-image/

Note: The VM needs to be in the same storage account as the uploaded VHD file.

To fix it, you can do something along these lines before you deploy the first VM:

$SourceContext = (Get-AzureRmStorageAccount -ResourceGroupName $VhdSourceResouceGroup -StorageAccountName $VhdSourceStorageAccount).Context

$DestinationContext = (Get-AzureRmStorageAccount -ResourceGroupName $resourceGroupName -StorageAccountName $VhdStorageAccount).Context

New-AzureStorageContainer -Name "source" -Context $DestinationContext -ErrorAction Ignore

Start-AzureStorageBlobCopy `
            -SrcUri "$($SourceContext.BlobEndPoint)source/$Image" `
            -SrcContext $SourceContext `
            -DestContainer "source" `
            -DestBlob $Image -ConcurrentTaskCount 24 `
            -DestContext $DestinationContext | Get-AzureStorageBlobCopyState -WaitForComplete