Translate

Saturday, February 22, 2014

Automatic Virtual Machine Activation Step by Step


What is AVMA?
Automatic Virtual Machine Activation is a new Windows feature added in Windows Server 2012R2 microsoft-end-user-license-agreement-397x300that enables you to activate your Windows VMs without using a KMS server or even a network connection. As you spin up new virtual machines they will activate against the host Hyper-v server. This activation only lasts 7 days and then it needs to renew it’s activation. This is perfect for your Windows Datacenter Hyper-v hosts because you can
Two features of AVMA that no other activation method offers are:
  1. The ability to automatically activate virtual machines without a network connection
  2. Track virtual machine licenses from the host virtualization server, without requiring any access rights on the virtualized machine
(Other options for activation are: KMS server, MAK key, AD-based Activation)
How Does AVMA work?
Automatic Virtual Machine Activation requires a Hyper-v host server running Windows Server 2012 R2 Datacenter and it must be activated. The Virtual Machines must be 2012R2 or above to activate under AVMA. This includes 2012R2 Datacenter, Standard, and Essentials.
The guest VMs must have an AVMA product key configured on them. See the table blow for the key.
Windows Server 2012 R2 AVMA keys:
Edition AVMA key
Datacenter Y4TGP-NPTV9-HTC2H-7MGQ3-DV4TW
Standard DBGBW-NPF86-BJVTX-K3WKJ-MTB6V
Essentials K2XGM-NMBT3-2R6Q8-WF2FK-P36R2
* Licenses above were taken from http://technet.microsoft.com/en-us/library/dn303421.aspx
These keys can be installed during the install or installed at a later time.
The last piece of this is how the virtual machine talks to it’s Hyper host to get activated. The channel it uses is the “Data Exchange” that the para-virtualization drivers provide. This is a per VM setting and is enabled by default. You can verify that it is enabled by going into a VMs settings and then selecting the Integration Services. Make sure “Data Exchange” is checked.
AVMA1
AVMA also provides real-time reporting on usage and historical data on the license state of the virtual machine. This data is stored and available on the virtualization host server. There is no need to have any access or rights to the VMs on that server to access this information.
Step by Step directions to implement AVMA:
To use AVMA is easy just follow these 4 steps to virtual bliss:
  1. Install Server 2012R2 Datacenter
  2. Activate the server
  3. Add the Hyper-v Role
  4. Install a 2012R2 Virtual Machine and assign an AVMA key
If your virtual machine needs a key or already has a different key and you would like to give it an AVMA key there are a couple ways to achieve that. Here are two:
Using the GUI – Start the File Manager and Right click on “This PC”. From that dropdown list select “Properties”.
image
You will then get the System Screen. From here you select the Change Product key at the bottom right of the window. Put in one of the keys in the above table.
image

Another way to change the product key is to do it from a command prompt or script. This will need to run with administrative privileges.
Steps to Set the Product key from a command Prompt:
  • Click on the Start Button and type “CMD”   — (Welcome back Start Button)
  • Right click on the Command Prompt and select “Run as administrator” image
  • In the command window run the command slmgr /ipk <AVMA_key>
    Command in the example below:
    slmgr /ipk Y4TGP-NPTV9-HTC2H-7MGQ3-DV4TW image
Hope you found this fun and informative! –Brian Hot smile

This post is part of a series of posts by the US IT Pro Evangelist team. In this series we cover, Why Windows Server 2012 R2 is important, how to deploy, manage, configure any number of components in Windows Server 2012 R2. 
This series is deep technical content with lots of How To’s and Step-By-Step instructions. You will learn about storage, cloud integration, RDS, VDI, Hyper-V, virtualization, deduplication, Hyper-v replica, DNS, AD, DHCP, high availability, SMB, backup, PowerShell and much, much more! – See more at: http://itproguru.com/expert/2013/10/windows-server-2012-r2-launch-blog-series-why-win2012r2/

Create Backups of Virtual Machines in Windows Azure by using PowerShell


Microsoft Scripting Guy, Ed Wilson, is here. Welcome back Keith Mayer as our guest blogger today. This is Part 1 of a two-part series. In Part 2, we’ll restore virtual machines in Windows Azure from these backups.
Photo of Keith Mayer
Keith Mayer is a senior technical evangelist at Microsoft, and he focuses on the Windows infrastructure, datacenter virtualization, systems management, and the private cloud. Keith has over 20 years of experience as a technical leader of complex IT projects, in diverse roles, including network engineer, IT manager, technical instructor, and consultant. He has consulted and trained thousands of IT professionals worldwide on the design and implementation of enterprise technology solutions.
You can find Keith online at http://KeithMayer.com.
Windows Azure Infrastructure Services provides the ability to easily provision or migrate storage, virtual machines, and virtual networks to the global Windows Azure cloud platform by using a cost-effective Pay-As-You-Go model. In my prior Weekend Scripter posts, Getting Started with Windows Azure and PowerShell and Remoting the Cloud with Windows Azure and PowerShell, I provided an introduction to using Windows PowerShell for automated provisioning of Windows Azure cloud fabric resources and workloads running inside virtual machines in Windows Azure.
Once you’ve provisioned a few lab virtual machines on Windows Azure, you’ll likely want to create a backup copy of each virtual machine. This is particularly useful in test lab scenarios, so that you can quickly revert virtual machines back to a known state prior to performing a set of tests.
When you are working in the on-premises world, this is typically performed via virtual machine backup, snapshot, or checkpoint capabilities. In Windows Azure, back up and restore of virtual hard disks can be quickly performed in the cloud with the Windows Azure PowerShell Module by leveraging the Start-AzureStorageBlobCopy cmdlet. However, there’s a bit of work we’ll need to do upfront to capture the information we’ll need for completing this process.
In this post, we’ll step through the process of building a Windows PowerShell script to back up virtual machines in Windows Azure. At the end of this post, I’ve provided a link to the next step, restoring virtual machines in Windows Azure, so that you’ll have the complete end-to-end process.
To back up virtual machines in Windows Azure, we’ll step through the following tasks:
  • Select a virtual machine to back up
  • Identify each virtual hard disk
  • Create a cloud storage container for storing backups
  • Back up virtual machines to cloud storage in Windows Azure
Note  To learn more about the basics of Windows Azure Infrastructure Services, you might also be interested in the “Early Experts” Cloud Quest and our scenario-based Cloud Labs step-by-step guides. Both are free online study resources that provide hands-on lab exercises for leveraging Windows Azure and building key IT pro cloud scenarios.

Select virtual machine to back up

The virtual machine you want to back up and restore can be selected by using the Get-AzureVM cmdlet. Running Get-AzureVM alone returns a list of virtual machines that are currently provisioned in Windows Azure.
Image of command output
  Get-AzureVM cmdlet output
To select a particular virtual machine, you can pass the ServiceName and Name values as parameters and set the output to a new Windows PowerShell variable.
Image of command output
  Selecting a Windows Azure virtual machine
Now our selected Windows Azure virtual machine can be referenced by using the variable $vm in the remainder of our script.
To capture a valid backup of each virtual hard disk, we also need to temporarily shut down the virtual machine to a state where the virtual machine is not running, but its configuration is kept in a provisioned state. We can accomplish this with the Stop-AzureVM cmdlet.
Image of command output
  Using Stop-AzureVM with the StayProvisioned parameter
Now that our virtual machine is selected and in the right state, we can proceed to the next step of finding each virtual hard disk we want to back up and restore.

Identify virtual hard disks

Virtual machines in Windows Azure can be provisioned with two general types of virtual hard disks: operating system disks and data disks. Each virtual machine will have one operating system disk from which it boots and runs the operating system. In addition, each virtual machine can have one or more additional data disks on which program code and data files can be stored. To perform a complete virtual machine backup, we’ll need to locate all of the virtual hard disks that our virtual machine is currently using.
To store the location for the operating system disk, we can use the Get-AzureOSDisk cmdlet.
Image of command output
  Locating the virtual machine operating system disk with Get-AzureOSDisk
For any virtual hard disk that we want to back up or restore, the two property values in which we’ll be most interested are the DiskName and MediaLink values, which are shown in the following image. These values provide the information that we’ll need to properly back up and restore each virtual hard disk that is associated with a virtual machine.
Image of command output
  Common property values for a Windows Azure virtual hard disk
To store the location for all data disks, we can use the Get-AzureDataDisk cmdlet. Because virtual machines can be provisioned with multiple data disks, this cmdlet returns of a collection of data virtual hard disks.
Image of command output
  Storing location for data disks with the Get-AzureDataDisk cmdlet

Create cloud storage container for storing backups

Prior to performing a backup, we’ll need to make sure that a container exists in our Windows Azure Storage Account to store these backup copies. First, we’ll need to determine the name of our Windows Azure Storage Account. We can do this by leveraging the MediaLink property of Azure Disks mentioned earlier.
Image of command output
  Determining the name of Windows Azure Storage Account by using MediaLink property
Now that we know the name of our Windows Azure Storage Account, we’ll want to set it as the current storage account for the remainder of our script by using the Set-AzureSubscription cmdlet.
Image of command output
  Setting the current storage account
Next, we can easily check to see if our desired container location for storing backups already exists inside our storage account, and if not, we can quickly create it by using the New-AzureStorageContainer cmdlet.
Image of command output
  Creating a new Windows Azure storage container
We can confirm that the new storage container has been created by using the Get-AzureStorageContainer cmdlet without parameters.
Image of command output
  Confirming creation of storage container with Get-AzureStorageContainer cmdlet
Now, we’re ready to back up our virtual machine!

Back up virtual machines in Windows Azure to cloud storage

To create a backup copy of the operating system disk on our virtual machine, we’ll first set the values for a couple variables that identify the blob and container names for the virtual disk that we want to back up. Then, we’ll use the Start-AzureStorageBlobCopy cmdlet to begin the copy process to our previously defined backup container location.
Image of command output
  Using Start-AzureStorageBlobCopy cmdlet to back up virtual hard disk
It’s important to note that the copy process performed by the Start-AzureStorageBlobCopy cmdlet is asynchronous in nature, and it runs in the background on the Windows Azure platform. To ensure that the copy process has completed before continuing with the next line in a script, we can use the Get-AzureStorageBlobCopyState cmdlet to wait until the copy process is finished.
Image of command output
  Using Get-AzureStorageBlobCopyState to confirm that the copy process completed
To back up our Windows Azure data disks, we’ll use a similar set of cmdlets, but we’ll run them inside a ForEach loop because Windows Azure data disks are returned as a collection.
Image of command output
  Back up data disks by using ForEach loop
After the backup process has completed, use the Get-AzureStorageBlob cmdlet to confirm that a copy of each virtual hard disk now exists in the backup storage container location.
Image of command output
  Using Get-AzureStorageBlob to confirm backup copies
Our backup process is complete, and we can now restart the Windows Azure virtual machine by using the Start-AzureVM cmdlet.
Image of command output
  Using Start-AzureVM to restart virtual machine after back up is complete
Congratulations! But keep learning!
You’ve completed the process for creating cloud backups of virtual machines in Windows Azure with Windows PowerShell! You can use the cmdlets and snippets in this post to quite easily build an automated approach to capture a backup of each Windows Azure virtual machine in your subscription, perhaps on a nightly basis.
In Part 2 of this series, we’ll walk through the process of restoring virtual machines in Windows Azure from these backups so that you can automate the complete end-to-end backup and restore process.
In addition, you may want to leverage these resources to continue your learning about Windows Azure Infrastructure Services:
Thank you, Keith, for sharing your time and knowledge.
I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.
Ed Wilson, Microsoft Scripting Guy

 
Design by IT Manager | Bloggerized by Themes For IT Managers | MIS-DUONG