none
Migrate Converted VHD to Azure Stack

    Question

  • Hi everyone,

    I currently work as a Microsoft Consultant for my company.

    Currently I have been testing migrating a converted VHD from VMDK to Azure. Now what I mention below works perfectly fine in Public Azure, but errors out in Stack.

    Steps I have taken 

    1. I've tried uploading the VHD to my Blob Storage and Creating a VM with it with the below commands ( I edited a bit so its not all my info). I created the VNET, NIC and Public IP already so it's attached after the fact.

    #Set Variables
    $resourceGroupName = "resourcegroupname"
    $virtualNetworkName = "vnetname"
    $NIC = "Nic ID"
    $destinationVhd = "https://test.blob.location.ismazure.com/storageaccount/TestVHD2016.vhd"

    #Upload VHD to Blob Storage
    Add-AzureRmVhd -ResourceGroupName $resourceGroupName -Destination $destinationVhd `  -LocalFilePath "E:\2016 VHD\TestVHD2016.vhd"

    #Configure VM

    $vmConfig = New-AzureRmVMConfig -VMName "TestVHD2016" -VMSize "Standard_DS2"
    $vmConfig = Set-AzureRmVMOSDisk -VM $vmConfig -Name "TestVHD2016" -VhdUri $destinationVhd `
                                    -CreateOption Attach -Windows
    $vmConfig = Add-AzureRmVMNetworkInterface -VM $vmConfig -Id $NIC

    #Create VM

    $vm = New-AzureRmVM -VM $vmConfig -Location $locationName -ResourceGroupName $resourceGroupName

    2. After this is ran, it will fail after 5 or 10 minutes with the error:

    New-AzureRmVM : Long running operation failed with status 'Failed'. Additional Info:'Vm Extensions cannot be installed on VM 'TestVHD2016 as guest agent is not provisioned on the VM.'
    StartTime: 11/30/2017 2:22:23 PM
    EndTime: 11/30/2017 2:22:54 PM
    OperationID: 91b510b9-e0e0-4bb0-bf8a-5d334f3c35e1
    Status: Failed
    ErrorCode: VMExtensionProvisioningError
    ErrorMessage: Vm Extensions cannot be installed on VM 'TestVHD2016 as guest agent is not provisioned on the VM.
    At line:10 char:7

    Actual Error from Azure

    OPERATION NAME Microsoft.Compute/virtualMachines/extensions/write
    STATUS Failed
    EVENT TIMESTAMP Thu Nov 30 2017 14:22:58 GMT-0600 (Canada Central Standard Time)
    UTC TIMESTAMP Thu, 30 Nov 2017 20:22:58 GMT
    CALLER User@xxxxxx.com
    AUTHORIZATION 
    action:Microsoft.Compute/virtualMachines/extensions/write role: scope:/subscriptions//resourceGroups/vhdluketest/providers/Microsoft.Compute/virtualMachines/TestVHD2016/extensions/BGInfo
    RESOURCE URI /subscriptions//resourcegroups/vhdluketest/providers/Microsoft.Compute/virtualMachines/TestVHD2016/extensions/BGInfo
    EVENT SUBMISSION TIMESTAMP Thu Nov 30 2017 14:23:21 GMT-0600 (Canada Central Standard Time)
    OPERATION ID 796a3f46-f386-4b95-97e0-f13f2c0ab173
    CORRELATION ID 76404bb6-751c-40b1-a3ae-3a6354f76861
    LEVEL Error
    RESOURCE GROUP vhdluketest
    RESOURCE PROVIDER Microsoft.Compute
    CATEGORY Administrative
    PROPERTIES 
    statusMessage:{"status":"Failed","error":{"code":"ResourceOperationFailure","message":"The resource operation completed with terminal provisioning state 'Failed'.","details":[{"code":"VMExtensionProvisioningError","message":"Vm Extensions cannot be installed on VM 'TestVHD2016 as guest agent is not provisioned on the VM."}]}}

    Now I even installed the Azure Agent before Uploading. Another thing I tried was uploaded into Public Azure, Created a VM, then Downloaded it back so the Agent and Extension was in OK status and still same error. The server I can see is up in Boot Diagnostics, but it's in status Failed and can't remove that Status. **I also wish there was a way to clear this status because the server is indeed functioning**

    The guest agent I installed from the link in here https://docs.microsoft.com/en-us/azure/virtual-machines/windows/agent-user-guide

    As of right now I am not sure what else I can try. There is another way to create a VM with an Image (Like so https://docs.microsoft.com/en-us/azure/virtual-machines/windows/upload-generalized-managed) but I need to Sysprep and Generalize which we do not want to do. Although that did not work in stack either. 

    Anyone have any luck with uploading VHD and Creating a VM out of it on Stack let me know. Stack is so new that there it's hard to find information on.



    Thursday, November 30, 2017 8:54 PM

Answers

  • Sorry for late response.... I did try having doing the Public Azure method first and then retrying to stack which did not work. It appears it would default trying to install BGInfo extension which isn't added into Stack yet. I worked with one of our great scripters and was able to deploy it with a Template script in Visual Studio.... Similar to the code below:

    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "vmName": {
                "type": "String",
                "metadata": {
                    "description": "VM name"
                }
            },
            "osDiskVhdUri": {
                "defaultValue": "URI OF MY VHD in BLOB",
                "type": "String",
                "metadata": {
                    "description": "Uri of the existing VHD"
                }
            }
        },
        "variables": {
            "vnetName": "vhdluketest",
            "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]",
            "subnetName": "vhdluketest",
            "subnetRef": "[concat(variables('vnetID'), '/subnets/', variables('subnetName'))]",
            "vmNICName": "[concat(parameters('vmName'),'-nic01')]"
        },
        "resources": [
            {
                "type": "Microsoft.Network/networkInterfaces",
                "name": "[variables('vmNICName')]",
                "apiVersion": "2015-06-15",
                "location": "[resourceGroup().location]",
                "properties": {
                    "ipConfigurations": [
                        {
                            "name": "ipconfig",
                            "properties": {
                                "privateIPAllocationMethod": "Dynamic",
                                "subnet": {
                                    "id": "[variables('SubnetRef')]"
                                }
                            }
                        }
                    ]
                }
            },
            {
                "type": "Microsoft.Compute/virtualMachines",
                "name": "[parameters('vmName')]",
                "apiVersion": "2016-03-30",
                "location": "[resourceGroup().location]",
                "properties": {
                    "hardwareProfile": {
                        "vmSize": "Standard_D1_v2"
                    },
                    "storageProfile": {
                        "osDisk": {
                            "name": "TestVHD2016.vhd",
                            "osType": "Windows",
                            "caching": "ReadWrite",
                            "vhd": {
                                "uri": "[parameters('osDiskVhdUri')]"
                            },
                            "createOption": "Attach"
                        }
                    },
                    "networkProfile": {
                        "networkInterfaces": [
                            {
                                "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('vmNICName'))]"
                            }
                        ]
                    }
                },
                "dependsOn": [
                    "[resourceId('Microsoft.Network/networkInterfaces', variables('vmNICName'))]"
                ]
            }
        ]
    }

    Thursday, December 07, 2017 9:19 PM

All replies

  • Hello,

    It would appear as if there is an issue provisioning/validating the Guest Agent.

     

    Can you try exporting your VM/VHD from public Azure without the guest agent and retry adding to Azure Stack again?  

     

    Let us know how it goes.

          

    We apologize for any inconvenience and appreciate your time and interest in Azure Stack.

    If you experience any issues with Azure Stack or the current ASDK release, please feel free to contact us.

           

     Thanks


    Gary Gallanes

    Thursday, December 07, 2017 8:34 PM
    Moderator
  • Luke, did you ever get a resolution to this?

    Brian Laws (Cloud Architect, Summit 7 Systems)

    Thursday, December 07, 2017 8:44 PM
  • Sorry for late response.... I did try having doing the Public Azure method first and then retrying to stack which did not work. It appears it would default trying to install BGInfo extension which isn't added into Stack yet. I worked with one of our great scripters and was able to deploy it with a Template script in Visual Studio.... Similar to the code below:

    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "vmName": {
                "type": "String",
                "metadata": {
                    "description": "VM name"
                }
            },
            "osDiskVhdUri": {
                "defaultValue": "URI OF MY VHD in BLOB",
                "type": "String",
                "metadata": {
                    "description": "Uri of the existing VHD"
                }
            }
        },
        "variables": {
            "vnetName": "vhdluketest",
            "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]",
            "subnetName": "vhdluketest",
            "subnetRef": "[concat(variables('vnetID'), '/subnets/', variables('subnetName'))]",
            "vmNICName": "[concat(parameters('vmName'),'-nic01')]"
        },
        "resources": [
            {
                "type": "Microsoft.Network/networkInterfaces",
                "name": "[variables('vmNICName')]",
                "apiVersion": "2015-06-15",
                "location": "[resourceGroup().location]",
                "properties": {
                    "ipConfigurations": [
                        {
                            "name": "ipconfig",
                            "properties": {
                                "privateIPAllocationMethod": "Dynamic",
                                "subnet": {
                                    "id": "[variables('SubnetRef')]"
                                }
                            }
                        }
                    ]
                }
            },
            {
                "type": "Microsoft.Compute/virtualMachines",
                "name": "[parameters('vmName')]",
                "apiVersion": "2016-03-30",
                "location": "[resourceGroup().location]",
                "properties": {
                    "hardwareProfile": {
                        "vmSize": "Standard_D1_v2"
                    },
                    "storageProfile": {
                        "osDisk": {
                            "name": "TestVHD2016.vhd",
                            "osType": "Windows",
                            "caching": "ReadWrite",
                            "vhd": {
                                "uri": "[parameters('osDiskVhdUri')]"
                            },
                            "createOption": "Attach"
                        }
                    },
                    "networkProfile": {
                        "networkInterfaces": [
                            {
                                "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('vmNICName'))]"
                            }
                        ]
                    }
                },
                "dependsOn": [
                    "[resourceId('Microsoft.Network/networkInterfaces', variables('vmNICName'))]"
                ]
            }
        ]
    }

    Thursday, December 07, 2017 9:19 PM
  • Thanks a ton, Luke! This is going to come in hugely helpful when it's my turn to start migrating VMs onto Azure Stack. We appreciate you sharing. 

    Brian Laws (Cloud Architect, Summit 7 Systems)

    Friday, December 08, 2017 1:40 PM