Windows Server 2012 R2 Datacenter Not Activating on Microsoft Azure

I noticed a strange behavior on VMs that are running on Microsoft Azure:

Activate Windows
Go to System in Control Panel to activate Windows

Strangely enough, it did not happen on all machines, just a few. Apparently the problem is known to Microsoft and they are working on a fix for that.

After searching the net for a solution i stumbled upon this solution which works fine for me:

  • Disable KMS host cache
  • Set KMS Server
  • Activate

Open up a command prompt with elevated privileges and execute the following:
cscript %windir%\system32\slmgr.vbs /ckhc
As a result you should see now: KMS host caching is disabled
Next execute:
cscript %windir%\system32\slmgr.vbs /skms kms.core.windows.net:1688
You get as a result: Key Management Service machine name set to kms.core.windows.net:1688 successfully.
Finally execute:
cscript %windir%\system32\slmgr.vbs /ato
And you should get as a result: Product activated successfully.

Hope this helps.