0
votes

I am using PowerShell ISE. When I run Add-AzureDisk I get a CLI wizard and fill in the DiskName and I have the vhd file uri in my clipboard (copied from the portal) When I use the uri without "..." I get:

Add-AzureDisk : Invalid URI: cannot parse the hostname.

At line:1 char:1

  • Add-AzureDisk
  • ~~~~~~~~~~~~~
    • CategoryInfo : NotSpecified: (:) [Add-AzureDisk], UriFormatException
    • FullyQualifiedErrorId : System.UriFormatException,Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.AddAzureDisk Command

When I do use the "uri here" I get:

Add-AzureDisk : Invalid URI: URI-scheme is invalid. At line:1 char:1

I used this button:

enter image description here

I started to think that my powershell modules are out of date or something, so I ran Get-Module AzureRm.Profile -ListAvailable as suggested here:

Directory: C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager

ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 4.0.0 AzureRM.Profile {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave,...

But I also have v5 (found this on the docs website):

Get-Module -ListAvailable -Name AzureRm.Resources | Select Version

Version

5.0.0

As you might have guessed, I am more used to the webportal. But I am trying to create a new vm with two unmanaged disks vhd's which are in my blob storage container.

Edit I tried the Azure CLI:

az vm create -n "tmp-vm" -g "resource-tmp" --attach-os-disk "https://the-uri-copied-from-ui.blob.core.windows.net/vhd-container/vm-osdisk.vhd" --size Standard_DS1_v2 --use-unmanaged-disk --os-type windows

and got:

At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details. 
{
  "status": "Failed",
  "error": {
    "code": "ResourceDeploymentFailure",
    "message": "The resource operation completed with terminal provisioning state 'Failed'.",
    "details": [
      {
        "code": "DiskBlobPendingCopyOperation",
        "message": "Disk blob https://the-uri-copied-from-ui.blob.core.windows.net/vhd-container/vm-osdisk.vhd is not ready. Copy state: Failed. Please retry when the blob is ready."
      }
    ]
  }
}  Correlation ID: 0e1231a9-aa0e-4d79-8953-92ea43c658eb

I created the vhd with the powershell commands that I have found here: https://stackoverflow.com/a/45569760/169714 perhaps that failed? I did not got an error or anything? How can I consolidate it?

edit2 I tried both templates and had a hard time getting the debug info. But I have found the error now. And it is the same as before:

enter image description here

The blob seems to have the expected size. The lease state says available. Last modified date is a second ago, so does that mean that the underlying storing is still in process? I tried to run Get-AzureStorageBlobCopyState -Blob tmpvmosdisk.vhd -Container vhd-containers -WaitForComplete but that gives an error about a non required (and unknown to me) argument: Get-AzureStorageBlobCopyState : Could not get the storage context. Please pass in a storage context or set the current storage context.

edit 3 data disk seems flushed again. It was 512gb and is now back to zero? enter image description here

so I got the not ready message again when I wanted to add the vhd as disk...

2
If you want to add a data disk to an Azure VM use: Add-AzureDataDisk Reference: docs.microsoft.com/en-us/powershell/module/azure/…Vikranth S
It's not just a data disk. It's primary the OS disk because I do not want managed disks but the cheaper unmanaged disks. So I stored a snapshot (I think/hope) in a blob container and want to create a vm with that.JP Hellemons

2 Answers

1
votes

As Hannel said, Add-AzureDisk is a classic command. You could not use it to create a ARM mode VM.

--attach-os-disk it requires a managed disk, now, you give a unmanaged disk(VHD), so, you get the error log. See this link.

According to your scenario, the easy way is to create VM with a template. You could use this template:Create a Virtual Machine from a User Image.

If you have existing VNet, you also could use this template.

1
votes

I can highlight multiple issues, i will try to answer all as best as i can.

First, Add Add-AzureDisk is a ASM (Classic Deployment) command but you are mentioning AzureRM Module. Is it an ARM or ASM deployment?

Second, you CLI is ARM deployment, that failed because you copied the VHD and the copy operation is not yet done so you cannot used the VHD. You should be able use the az storage blob show command to validate the VHD copy/move is completed before using VHD.

Hope this helps.