Social Icons

twitter google plus linkedin rss feed

Pages

Featured Posts

22.9.15

How To Clone a Virtual Machine in Azure

This is quite simple, once you know how to do it but... when you don't...

My favourite way of cloning virtual machines has always been copying the hard disks and deploying the virtual machine in a different network segment. We do have all the ingredients we need for this recipe in Azure so let's get to it!

You will need:

  • The blob that contains the vhd you want to clone
  • A new Cloud Service (or one where the source virtual machine is not running)
  • Notepad.exe (or similar, although nothing beats the original)
  • Azure PowerShell
  • Attention to detail
  • Just a bit of patience
Let's start.

The first thing you need to do is to find out the disk(s) you want to clone. In the virtual machine's dashboard page, if you scroll down a bit, you will be able to see them.

After you scroll down do not forget to scroll right too, the URL we need is a bit hidden... copy it in your notepad.

This is the address of the blob that contains the disk and in it you can find:

http://[yourStorageAccount].blob.core.windows.net/[yourContainerName]/[yourBlobName].vhd

Finally you need  the primary access key for your storage account. 

Go to Storage, select your Storage Account and look on the footer of the page for the key icon:


There copy your primary key and paste it to your notepad.

And that's all you need.

#From http://michaelwasham.com/windows-azure-powershell-reference-guide/copying-vhds-blobs-between-storage-accounts/
#And after that from http://www.codegrimoire.com
####################################################################################################################
### Source VHD - anonymous access container ###
$storageUri = "http://yourStorageAccount.blob.core.windows.net/"
$containerName = "yourContainerName" ##I am using the same source and destination here
$sourceBlobName = "yourBlobame.vhd"

### Destination Blob
$destBlobName = "newBlobName.vhd"

######### New Disk Name
$newDiskName =  "newDiskName"
$newDiskLabel = "BootDisk" ##In the documentation it is either BootDisk or DataDisk but you can call it something else
$isOsDisk = $true ##$true Or $false. As I only work with windows I will not bother about other OSs in this script

### Target Storage Account ###
$storageAccount = "yourStorageAccount"
$storageKey = "yourPrimaryKey" ##Primary Access Key


###################################################################################
############  Automated script for creating the new VHD  ##########################
###################################################################################

$srcUri = ($storageUri.trim('/'), $containerName.trim('/'), $sourceBlobName) -join '/'
$destUri = ($storageUri.trim('/'), $containerName.trim('/'), $destBlobName) -join '/'
 
### Create the destination context for authenticating the copy
$destContext = New-AzureStorageContext  –StorageAccountName $storageAccount -StorageAccountKey $storageKey  
 
### Create the target container in storage
### Not necessary as i am using an existing one ### New-AzureStorageContainer -Name $containerName -Context $destContext 
 
### Start the Asynchronous Copy ###
$blob1 = Start-AzureStorageBlobCopy -srcUri $srcUri -DestContainer $containerName -DestBlob $destBlobName -DestContext $destContext

### Loop until complete ###                                    
Do{
  $status = $blob1 | Get-AzureStorageBlobCopyState 
  ### Print out status ###
  $status.Status
  Start-Sleep 5
}While($status.Status -eq "Pending") ##This doesn't work as you would expect but the idea is good and maybe they will change the way Get-AzureStorageBlobCopyState works :)


######## After the new blob has been created we will add the new disk #############
if ($isOsDisk){
    Add-AzureDisk -DiskName $newDiskName -MediaLocation $destUri -Label $newDiskLabel -OS "Windows"
}
else{
    Add-AzureDisk -DiskName $newDiskName -MediaLocation $destUri -Label $newDiskLabel
}

Once you edit the script with your data and run it you will have to wait for a couple of minutes before the new disk is available. You do not need to turn off the source virtual machine although it's better safe than sorry

After that go to Virtual Machines, New, Compute, Virtual Machine, From Gallery and choose My disks in the lower part of the left column:

The disk you have just created will appear in the list and after that you just need to create the new virtual machine normally.

By the way, we need an Azure + SharePoint administrator in London, do you oblige?


Is it a good idea to call the cloned VMs Dolly?

25.8.15

Windows 10 after the first month

Actually I had W10 installed in a preview back on January and only because I wanted to be careful not installing the first insider preview but then I found some very annoying bugs that made me uninstall it and go back to W8.1. Finally and  it looks like I mean Literally Finally as they say this is the last version of Windows ever I reinstalled The Real W10 on the 29th... And realised much more acquiescent than surprised that the bugs that made me uninstall it were already there.

It's pretty obvious that my bugs are due to my particular set up and they are nothing you need to worry about. Who would have two monitors daisy chained to a Surface 3 Pro and a HiFi system hooked to them? If you have that type of set up you probably deserve loosing the image in your monitors and waking up every morning without sound.

I already know how to work around these issues. If your monitors stop working you need to unplug them off from the wall (turning them off or disconnecting the DP cable will not do, you need to pull the plug off the wall) and back on again. That plus a reset fixes it. About the sound it's either changing the quality of the sound or restarting the machine but enough of my old man whining already.

I have been working with Windows 10 in my everyday computer for three or four months and the single thing that makes me love the system every day is the fact that is Desktop-Centrinc this is my innovative use of the English language again.

Windows 8 was based in apps and the operative system wanted to push you to use the apps first... Even the desktop was an app... The desktop... AN APP!? the more I think about it the more outrageous it feels. It kind of makes sense if you have a tablet but 99% of people who works with a computer does it sitting on their offices with two 24" monitors. The desktop an app ... that's nonsense.. an app....

Windows 10 runs from the desktop (in desktop computers) and that small change makes everything make sense again.

Your computer starts with your familiar desktop and there you have all your familiar applications you feel like home. Suddenly you need to download something... you can either use your familiar browser to go to the wilderness that it is internet and download a random piece of software from a random server that will have access to most of the resources in your computer without you noticing after installing a bar in the browser or you can go to the now natural place to download software: The Store.

The apps from the store work now as windows in the desktop. You can maximise them as you always could, you can stick them to a side of the screen as you always could and you can use it in all the usual ways with all the freedom you are used to. That is fantastic. That makes the boundary between a mobile device like a phone or a tablet and your desktop disappear. You can use the same app everywhere but if you are in your desktop you will be able to run it right besides your beloved Winamp (Why Winamp? because you always dreamed secretly about whipping a llama's ass).

I do not consider myself a common computer user, in fact the vast majority of the days I use just the remote desktop and maybe the browser for reading the news if I'm in that mood but since I have W10 I have downloaded a couple of apps that I use sometimes and the more apps you download and use the more natural it feels.

With Windows 10 the ability to run the apps in Windows phones is not be the driver to migrating programs to apps any more. Windows programs are so from the 80's...

If the integration between apps and EXEs is so seamless and apps are the coolest thing around, Why have not all the companies migrated all the code from the last 10 years to apps already? After all it has been a month since they released Windows 10...

Because it took them 10 years to create that code in the first place.

I'm not saying that migrating an app would take the same amount of time than creating it from scratch but it's still an investment. It will mean migrating, at least, the whole user experience and, How often do programs change their user interface?


I suspect the risk adverse software companies (or the bigger ones that take longer to react) will wait until they need an interface change to adopt the new paradigm while the new software companies and the more dynamic ones will embrace the apps world as soon as they release a new version.

What do you think?