Monday, September 30, 2013

Microsoft Dynamics AX 2012 in Windows Azure (IaaS) – Using Existing VHD

Microsoft Dynamics AX 2012 in Windows Azure (IaaS) – Using Existing VHD
Purpose: The purpose of this document is to explain how to deploy Microsoft Dynamics AX 2012 in Windows Azure platform (Infrastructure-as-a-Service (IaaS)) using existing VHD (Virtual Hard Drive). 
Challenge: You may want to deploy Microsoft Dynamics AX 2012 as Infrastructure-as-a-Service (IaaS) for the purposes of POC (Proof of concept), in case you want to have additional development or test environment, or if you are considering deploying production instance of Microsoft Dynamics AX 2012 in the Cloud. There're number of options when deploying Microsoft Dynamics AX 2012 in the Cloud including Windows Azure platform. And in many cases you already have a virtual machine which you have built locally, and you want to deploy this virtual machine to the Cloud as Windows Azure VM.
Solution: To store files and data in the Blob, Table, and Queue services in Windows Azure, you can create a storage account in the geographic region where you want to store the data. A Windows Azure virtual machine is created from an image or a disk. All virtual machines use one operating system disk, a temporary local disk, and possibly multiple data disks. All images and disks, except the temporary local disk, are created from virtual hard disks (VHDs), which are .vhd files stored as page blobs in a storage account in Windows Azure. You can use platform images that are available in Windows Azure to create virtual machines, or you can upload your own images to create customized virtual machines. The disks that are created from images are also stored in Windows Azure storage. You can easily create new virtual machines from existing disks.
In this scenario I want to deploy existing VHD which contains Microsoft Dynamics AX 2012 installation to Windows Azure platform (Infrastructure-as-a-Service (IaaS)). In particular I want to establish Microsoft Dynamics AX 2012 Demo environment in Windows Azure using Microsoft Dynamics AX 2012 A Demo VM which you can download from Partner Source here.
Please note that there's a tutorial available on how to upload VHD which contains Windows Server OS to Windows Azure: However there're number of nuances about Microsoft Dynamics AX 2012 A Demo VM which I will describe in this document. That's why please review the rest of this document before you take further actions.
We will start off with creation of Windows Azure Storage account as described below
After that we can create a container to put our VHD file into
The initial idea would be to upload VHD file and create an image based on it. And at this step we want to make sure that our VHD file is not bigger than 128GB because currently there's a limitation related to VHD upload to Windows Azure which states that VHDs up to 128GB are allowed
In case you upload Microsoft Dynamics AX 2012 A Demo VM to Windows Azure Storage account
You will end up with 175GB VHD
And you will see the following error "VHD has invalid size XGB. Permitted values are between 0 and 128GB" when you'll try to create an image based on this VHD
Now if we look at Microsoft Dynamics AX 2012 A Demo VM its total size is 175GB. Please note that there's about 70GB of free space there
Disk Management
Now we can look at possibilities to shrink VHD using standard Shrink function and we'll see that we can actually shrink it to about 128GB
Disk Management
We can further explore options on how to shrink it even more using Disk Cleanup function and again there's such possibility (-1GB) which brings us to 127GB desired size
Disk Management
Please note that after you shrink a disk using Disk Management Shrink function shrank space becomes Unallocated and VHD size is still 175GB. That's why we need to resize VHD properly to desired size of 127GB. In this scenario I used VHDResizer utility which you can download for free in the internet
Please note that another important point is to change the type of VHD from Dynamic to Fixed to control its size after we upload it to Windows Azure Storage account. I also specified new size of 127GB which is smaller than 128GB limit
Please note that technically we could use Resize-VHD command in Windows Server 2012: But currently the only VHD format is supported in Windows Azure for creation of images, and Resize-VHD command only works for VHDX format
After you resize VHD you can give unallocated space back to VM in Disk Management by using Extend function. This is why if I now run this VM locally (Hyper-V) I can see the C: drive has actual size of 127GB. Exactly what I need for now!
Disk Management
Now we can finally upload VHD to Windows Azure Storage account using Windows Azure PowerShell Cmdlet as shown below
Windows Azure PowerShell
Please note that upload may take a while depending on the speed of your internet (upload speed)
The resulting outcome may look like the following
PS C:\> Add-AzureVhd -Destination -LocalFilePath "D:\MicrosoftDynamicsAX2012\Virtual Hard Disks\AX2012R2A-v3.vhd"
MD5 hash is being calculated for the file D:\MicrosoftDynamicsAX2012\Virtual Hard Disks\AX2012R2A-v3.vhd.
MD5 hash calculation is completed.
Elapsed time for the operation:
Creating new page blob of size ...
Elapsed time for upload:
LocalFilePath                                               DestinationUri
-------------                                               --------------
D:\MicrosoftDynamicsAX2012\Virtual Hard Disks\AX20...
Now we can double check that the size of VHD uploaded is smaller than 128GB
Another important consideration is that for creation of images in Windows Azure based on VHD you have to sysprep the image (on VHD) itself
Please note that if you upload VHD which is not sysprep-ed in Windows Azure Storage account and then try to create an image based on it you will run into "Running (Provisioning Timed Out)" problem. This basically means that after you launch Windows Azure VM (created based on the not sysprep-ed image) your Windows Azure VM will show "Running (Provisioning Timed Out)" status and you will not be able to use it
Virtual Machines
Please note that even after you sysprep Microsoft Dynamics AX 2012 A Demo VM you may not be able to launch it after that because of hardware drivers errors. Also there're more considerations about sysprep-ing machines with Microsoft SQL Server and Microsoft SharePoint Server installed
That's why I decided to convert uploaded VHD into Disk instead of Image and then attach this Disk to the Windows Azure VM. Let's move on … Currently I don't have any Virtual Machines created
Virtual Machines
I will switch over to Disks
And create a new Disk based on uploaded VHD
Create a disk from a VHD
Please note that I attached uploaded VHD to the Virtual Machine Disk and also specified that VHD contains Windows OS
Browse Cloud Storage
Now we can see Disk in the list. Please note that this disk has not been attached to the Virtual Machine yet
As a next step we can create Virtual Machine based on the Disk
Create a Virtual Machine – Virtual Machine image selection
Then I can define the size of Virtual Machine and user credentials. Please note that I specified "A7 (8 cores, 56GB memory) size because Microsoft Dynamics AX 2012 A Demo VM is a single-box install of Microsoft Dynamics AX 2012
Create a Virtual Machine – Virtual Machine configuration
Create a Virtual Machine – Virtual Machine configuration
Create a Virtual Machine – Virtual Machine configuration
At last Virtual Machine has been created, started and now it is Running
Virtual Machines
In case you want to monitor the availability and performance of applications that are running on Windows Azure you can use standard Dashboards and Views on Windows Azure Portal online
Or you can locally install System Center Monitoring Pack for Windows Azure Applications:
Now you can Connect to it through RDP
Microsoft Dynamics AX 2012: Success!
In conclusion let's quickly summarize the key points about Custom Images and Disks in Windows Azure
Speaking about Images: You can upload VHDs up to 128GB size to create an image based on it. Your images will be available in the gallery under "My Images". You will have to sysprep image before upload. VHD format is required, VHDX does not work (to convert you can use Actions > Edit disk). VHD must have Fixed type and not Dynamic. You can upload VHD using Add-AzureVhd Cmdlet.
Speaking about Disks: C: drive is persistent, uses storage as a backing store. D: is a temporary drive. The size of the machine affects data disk use cases. Your disks will be available in the gallery under "My Disks". From performance and scaling perspective temp disk is fast, but volatile, you can also attach multiple disks and stripe data between them to increase throughput. Disk performance factors are significantly different from on premise solutions that's why you will want to test the performance early. For Performance Guidance for SQL Server in Windows Azure Virtual Machines please review the following White Paper:
Summary: This document describes how to deploy Microsoft Dynamics AX 2012 Demo environment in Windows Azure platform (Infrastructure-as-a-Service (IaaS)) using existing VHD (Virtual Hard Drive). Please note that in described deployment of single-box installation of Microsoft Dynamics AX 2012, and you can deploy distributed installation of Microsoft Dynamics AX 2012 if needed using existing VHDs and/or newly deployed Virtual Machines in any combination.  Please learn more about Windows Azure storage here: Please also get familiar with details of how to manage Windows Azure Disks and Images here:

Author: Alex Anikiev, PhD, MCP
Tags: Microsoft Dynamics AX 2012, Windows Azure, Microsoft Cloud, IaaS, Infrastructure as a Service, Demo VM, Storage account, Image, Disk
Note: This document is intended for information purposes only, presented as it is with no warranties from the author. This document may be updated with more content to better outline the concepts and describe the examples.


  1. Hi Alex,

    When using the Azure Disk Image approach you suggested to create the Dynamics AX VM, do I need to SysPrep the image before the upload?

    Thanks for this post, it is exactly what I want to do.


    1. Hi Matthew!

      Thank you for the interest to this topic

      In case you add VHD as Disk there's no need to sysprep and the system (VM) will boot from the same exact VHD
      The difference between adding VHD as Disk and adding VHD as Image is that with latter you will create VM based on Image and the copy of VHD will be created for that VM. But because of multiple components were installed on AX 2012 Demo VM which may not work after sysprep I went with VHD Disk approach

      Best Regards,

  2. This comment has been removed by the author.

  3. This comment has been removed by the author.

  4. Hi Alex,

    Thanks For your documentation and it helps a lot for me.

    I got an issue after VM created for that uploaded vhd in azure for the VM I am unable to login to the vm and I observed that hostname and rdp thumbprint is not generated for that vm. but in azure vm status it is showing Running.

    Thanks & Regards,

  5. HI Alex,


    Need a small clarification on below.

    I have a VM in my On-Prem with the hostname and ip- now I migrated this On-Prem vm to azure. Now in azure for this uploaded VHD I have created VM and it got new ip-address from azure network, now this record will automatically change my On-Prem existing DNS hostname record or I need to create a new hostname record with new ip-address for this uploaded azure VM.

    And also tell me what all the changes happend to the VM. (hostname, ipaddress, dns hostname records).
    Kindly please provide the solution.ASAP.

    Thanks & Regards,
    Satish Kusumanchi