This script can be run inside a Windows VM that is going to be uploaded into Azure. The script is based on the instructions provided by Microsoft to prepare a VHD for Azure. Included in this script is also the installation of the Azure VM agent.
Please make sure you run this script as Administrator.
After running this script you have to make a choice to run sysprep or not. Then follow instructions on how to convert the VM disk to a VHD fixed size and upload to Azure Blob storage.