Thursday, 10 March 2016

Create and upload a Windows 7 or 8 VHD to Microsoft Azure


Step 1: Prep the VHD
Before you upload the VHD to Azure, it needs to be generalized by using the Sysprep tool. This prepares the VHD to be used as an image. For details about Sysprep, see How to Use Sysprep: An Introduction.

From the virtual machine that the operating system was installed to, complete the following procedure:

1.       Log in to the operating system.
2.       Open a command prompt window as an administrator. Change the directory to %windir%\system32\sysprep, and then run sysprep.exe.





3.       The System Preparation Tool dialog box appears.




4.       In the System Preparation Tool, select Enter System Out of Box Experience (OOBE) and make sure that Generalize is checked.
5.       In Shutdown Options, select Shutdown.
6.       Click OK.

Once the machine is shutdown, virtual hard disk file is ready to use upload to azure.

Step 2: Create or get info from your Azure storage account
You need a storage account in Azure so you have a place to upload the .vhd file. This step shows you how to create an account, or get the info you need from an existing account.

Option 1: Create a storage account

1. Sign in to the Azure classic portal.
2. On the command bar, click New.
3. Click Data Services > Storage > Quick Create.



4. On below page select as per your requirements.



5. Click Create Storage Account. The account now appears under Storage.







6.       Next, create a container for your uploaded VHDs. Click the storage account name and then click Containers.



7.       Click Create a Container.



8.       Type a Name for your container and select the Access policy.



Option 2: Get the storage account info

1.       Sign in to the Azure classic portal.
2.       From the navigation pane, click Storage.
3.       Click the name of the storage account, and then click Dashboard.
4.       From the dashboard, under Services, hover over the Blobs URL, click the clipboard icon to copy the URL, then paste and save it. You'll use it when you build the command to upload the VHD.


Step 3: Connect to your subscription from Azure PowerShell
Before you can upload a .vhd file, you need to establish a secure connection between your computer and your subscription in Azure. You can use the Microsoft Azure Active Directory method or the certificate method to do this.
Option 1: Use Microsoft Azure AD
1.       Open the Azure PowerShell console.
2.       Type:
Add-AzureAccount
3.       In the sign-in windows, type the user name and password of your work or school account.
4.       Azure authenticates and saves the credential information, and then closes the window.

Option 2: Use a certificate
1.       Open the Azure PowerShell console.
2.       Type: Get-AzurePublishSettingsFile.
3.       A browser window opens and prompts you to download a .publishsettings file. It contains information and a certificate for your Microsoft Azure subscription.



4.       Save the .publishsettings file.
5.       Type: Import-AzurePublishSettingsFile <PathToFile>
Where <PathToFile> is the full path to the .publishsettings file.

Step 4: Upload the .vhd file
When you upload the .vhd file, you can place the .vhd file anywhere within your blob storage.
1.       From the Azure PowerShell window you used in the previous step, type a command similar to this:
Add-AzureVhd -Destination "<BlobStorageURL>/<YourImagesFolder>/<VHDName>.vhd" -LocalFilePath <PathToVHDFile>

Where:
BlobStorageURL is the URL for the storage account
YourImagesFolder is the container within blob storage where you want to store your images
VHDName is the name you want the Azure classic portal to display to identify the virtual hard disk
PathToVHDFile is the full path and name of the .vhd file


Then this command will calculate MD5 Hash.


Once MD5 Hash will complete, then it will start uploading image to respective azure portal.



Step 5: Add the image to your list of custom images
TIP: To use Azure PowerShell instead of the Azure classic portal to add the image, use the Add-AzureVMImage cmdlet. For example:

Add-AzureVMImage -ImageName <ImageName> -MediaLocation <VHDLocation> -OS <OSType>
1.       From the Azure classic portal, under All Items, click Virtual Machines.
2.       Under Virtual Machines, click Images.
3.       Click Create an Image.



4.       In the Create an image from a VHD window:

·         Specify the name.
·         Specify the description.
·         Under VHD URL, click the folder button to open the Browse Cloud Storage window. Find the .vhd file, and then click Open.



5.       In the Create an image from a VHD window, under Operating System Family, select your operating system. Check I have run Sysprep on the virtual machine associated with this VHD to verify that you generalized the operating system, and then click OK.



6.       After you complete the previous steps, the new image is listed when you choose the Images tab.



7.       This new image is now available under My Images when you create a virtual machine. For instructions, see Create a custom virtual machine.



Step 6: Deploy the virtual machine from uploaded vhd.
1.       Click on NEW from Virtual Machine page.



2.       On NEW go to >COMUTE >VIRTUAL MACHINE > FROM GALLERY


3.       Now go to MY IMAGE and select you IMAGE, click Next button.


4.       Type Virtual Machine Name, User Name, Password and Select Machine Configuration, click Next button.



5.       On Next page, Select your CLOUD SERVICE or Create a New Cloud Service as per your requirement.


6.       Check the Install VM Agent, , click Next button.



That’s all about create and uploading image or VHD file to Azure and deploying virtual machine from your uploaded vhd on Microsoft Azure.
Unknown Server Administrator

Microsoft Certified Professional, CCNA, Windows Server Administrator, VMWare Administrator, Hyper-V Administrator, Virtualization Administrator

No comments:

Post a Comment