 <?xml-stylesheet type="text/css" href="https://www.esdm.co.uk/Data/style/rss1.css" ?> <?xml-stylesheet type="text/xsl" href="https://www.esdm.co.uk/Data/style/rss1.xsl" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
  <channel>
    <title>The knowledge base blog</title>
    <link>https://www.esdm.co.uk/knowledge</link>
    <description />
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>mojoPortal Blog Module</generator>
    <language>en-GB</language>
    <ttl>120</ttl>
    <atom:link href="https://www.esdm.co.uk/Blog/RSS.aspx?p=138~108~23" rel="self" type="application/rss+xml" />
    <itunes:owner />
    <itunes:explicit>no</itunes:explicit>
    <item>
      <title>Uploading disks and VMs to Azure</title>
      <description><![CDATA[<p><br />
&nbsp;</p>

<h1>Subscriptions</h1>

<p>Before you can upload anything to Azure you need to make powershell aware of your Azure subscriptions.</p>

<p><a href="http://yossidahan.wordpress.com/2012/12/12/azure-subscriptions-in-powershell-demystified/" title="http://yossidahan.wordpress.com/2012/12/12/azure-subscriptions-in-powershell-demystified/">http://yossidahan.wordpress.com/2012/12/12/azure-subscriptions-in-powershell-demystified/</a></p>

<p>These can be a minefield – especially if you have more than one and make a typo.</p>

<p>1) Delete any existing cached settings:&nbsp; Delete the xml file from&nbsp; ~\AppData\Roaming\Windows Azure Powershell</p>

<p>2) <strong>Get-AzureSubscription | select SubscriptionName, IsDefault</strong> (Should return nothing at this point)</p>

<p>3) <strong>Get-AzurePublishSettingsFile</strong> (asks you to logon and downloads a settings file with credentials)</p>

<p>4) <strong>Import-AzurePublishSettingsFile</strong> <em>"C:\Temp\MSDNcredentials.publishsettings</em>"</p>

<p>5) <strong>Get-AzureSubscription | select SubscriptionName, IsDefault </strong>(Should now return a list of your accounts and which is default)</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_106.png"><img alt="image" border="0" height="34" src="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_thumb_82.png" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" title="image" width="244" /></a></p>

<p>Note: If you have spaces in any of your account names – its best to cut and paste from the output from <strong>Get-AzureSubscription </strong>to make sure its character perfect!</p>

<h1>Prepare disk for upload.</h1>

<p>If you have a local list that you have been using in Hyper V and you want to upload to Azure you need to first convert it (make sure there are no differencing disks etc for it).&nbsp; Azure only supports fixed size (max 127GB) VHD disks (it doesn’t currently support vhdx disks)</p>

<p>If you need to convert a VHDX disk to a VHD you can do this using Convert-VHD</p>

<p>This HAS to be done using powershell on Windows 8 machine or later</p>

<p>Convert-VHD –Path c:\test\MY-VM.<b>vhdx</b> –DestinationPath c:\test\MY-NEW-VM.<b>vhd</b></p>

<p>If you are just uploading a data VM then its relatively straight forward and the above should be sufficient.<br />
<br />
If however you want to upload a bootable VM then there are a number of issues well described here: <a href="http://blogs.msdn.com/b/narahari/archive/2013/01/15/windows-azure-virtual-machines-gotcha-s.aspx" title="http://blogs.msdn.com/b/narahari/archive/2013/01/15/windows-azure-virtual-machines-gotcha-s.aspx">http://blogs.msdn.com/b/narahari/archive/2013/01/15/windows-azure-virtual-machines-gotcha-s.aspx</a></p>

<ul>
	<li>The biggest issue about uploading VMs to Azure is that there is no Console connection in Azure, the only option for connections is via RDP. So if everything is exactly correctthere is a high chance that your new VM will be running but not accessible once you get it on Azure with no option to correct it!</li>
	<li>VHD has to be &lt; 127 GB (Azure limit) – and thus applies to dynamic disk as well if the max size is &gt; than that.It Maybe able to use VHDResizer to shrink the disk – but only if nothing is towards the end of the disk so it may need defrag first (see:<a href="http://morgansimonsen.wordpress.com/2009/03/27/reducing-the-size-of-a-dynamically-expanding-vhd-file/" title="http://morgansimonsen.wordpress.com/2009/03/27/reducing-the-size-of-a-dynamically-expanding-vhd-file/">http://morgansimonsen.wordpress.com/2009/03/27/reducing-the-size-of-a-dynamically-expanding-vhd-file/</a>)</li>
	<li>The VM has to be generalised using sysprep – see: <a href="http://blogs.msdn.com/b/narahari/archive/2013/01/15/windows-azure-virtual-machines-gotcha-s.aspx" title="http://blogs.msdn.com/b/narahari/archive/2013/01/15/windows-azure-virtual-machines-gotcha-s.aspx">http://blogs.msdn.com/b/narahari/archive/2013/01/15/windows-azure-virtual-machines-gotcha-s.aspx</a>.&nbsp; A VM <strong>must be generalized</strong> to use as an <strong>image</strong> from which you will create other VMs</li>
</ul>

<pre>
<font face="Calibri">There is also an interesting looking tool here that is supposed to do the whole process – but on one quick try failed for me: <a href="http://cloudscraper.migrate2iaas.com/azuredownload" title="http://cloudscraper.migrate2iaas.com/azuredownload">http://cloudscraper.migrate2iaas.com/azuredownload</a></font></pre>

<h1><strong>Uploading disk</strong></h1>

<p>Again using powershell.&nbsp; The process is quite smart – although Azure only supports fixed sized disks -&nbsp; it checks for only written blocks to minimise file transfer size:</p>

<ul>
	<li>import-module azure</li>
	<li>select-azuresubscription "mysubscriptionname"&nbsp;&nbsp; $sourceVHD = "D:\StorageDemos\myvhd.vhd"</li>
	<li>$destinationVHD = <a href="https://mwwestus1.blob.core.windows.net/uploads/myvhd.vhd">https://mwwestus1.blob.core.windows.net/uploads/myvhd.vhd</a>&nbsp;</li>
	<li>Add-AzureVhd -LocalFilePath $sourceVHD -Destination $destinationVHD ` -NumberOfUploaderThreads 5</li>
</ul>

<pre>
<font face="Calibri">You get a nice progress indicator in Powershell as it uploads</font></pre>

<pre>
<font face="Calibri">From Telehouse a 20GB disk (Dynamic Hyper V Server 2008 R2 vhd) took about an hour.</font></pre>

<h1>How to snapshot and restore Azure vhds in powershell</h1>

<p>Good description here:</p>

<p><a href="http://blog.cerebrata.com/how-to-snapshot-and-restore-virtual-machines-running-on-windows-azure/" title="http://blog.cerebrata.com/how-to-snapshot-and-restore-virtual-machines-running-on-windows-azure/">http://blog.cerebrata.com/how-to-snapshot-and-restore-virtual-machines-running-on-windows-azure/</a></p>
<br /><a href='https://www.esdm.co.uk/uploading-disks-and-vms-to-azure'></a>&nbsp;&nbsp;<a href='https://www.esdm.co.uk/uploading-disks-and-vms-to-azure'>...</a>]]></description>
      <link>https://www.esdm.co.uk/uploading-disks-and-vms-to-azure</link>
      <author>()</author>
      <comments>https://www.esdm.co.uk/uploading-disks-and-vms-to-azure</comments>
      <guid isPermaLink="true">https://www.esdm.co.uk/uploading-disks-and-vms-to-azure</guid>
      <pubDate>Sun, 15 Jun 2014 18:33:00 GMT</pubDate>
    </item>
    <item>
      <title>Configuring certificates for Azure backup</title>
      <description><![CDATA[<p>Azure backup allows you to securely link one or more servers to a backup store.&nbsp; For some reason I had some initial difficulties getting the certificates to all line up – so this is a quick note of what worked.</p>

<p>Server 2012 and Server 2008 R2 are supported clients</p>

<p>Azure backup works using the Azure backup agent (downloadable from your Azure recover services, backup vault account.&nbsp; Having installed this the first step is to link the server that its installed on to the Azure backup vault.&nbsp; This requires a certificate.&nbsp; There are options to self generate – but seeing as we had a proper one I thought I’d use that.</p>

<ul>
	<li>Certificates must be imported into the local COMPUTER personal store.&nbsp; This is different from you own user personal store</li>
	<li>To do this I had to be logged on as Administrator, then Start / Run MMC&nbsp; and then Add Snap in for certificates and select personal computer</li>
	<li>Import pfx file here - making sure certificate ends up in Local computer personal store. Also make sure you import it with option to export</li>
</ul>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/media/wlw/clip_image002_5.jpg"><img alt="clip_image002" border="0" height="158" src="https://www.esdm.co.uk/Data/Sites/1/media/wlw/clip_image002_thumb_4.jpg" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" title="clip_image002" width="244" /></a></p>

<ul>
	<li>Then export the certificate as a .cer file default option will do (Don’t think you need to export the key)</li>
</ul>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/media/wlw/clip_image004_3.jpg"><img alt="clip_image004" border="0" height="167" src="https://www.esdm.co.uk/Data/Sites/1/media/wlw/clip_image004_thumb_3.jpg" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" title="clip_image004" width="244" /></a></p>

<ul>
	<li>In Azure – upload the certificate lo link this server to the azure backup account</li>
</ul>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/media/wlw/clip_image006_1.jpg"><img alt="clip_image006" border="0" height="169" src="https://www.esdm.co.uk/Data/Sites/1/media/wlw/clip_image006_thumb_1.jpg" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" title="clip_image006" width="244" /></a></p>

<ul>
	<li>You can then run through the Wizard connecting Azure Backup agent to the backup store.&nbsp; If all has gone well you will be offered your newly imported certificate to use.&nbsp; If you have gone wrong – it will say no certificate available.</li>
</ul>

<p>You will also be asked to generate a passphrase as the encryption key. Lose this and you will never recover your data if you need to re-install – so its suggested soring on USB stick securely.</p>

<h2>Costs:</h2>

<p>Currently first 5GB is free – then 0.18 pence per GB / month</p>
<br /><a href='https://www.esdm.co.uk/configuring-certificates-for-azure-backup'></a>&nbsp;&nbsp;<a href='https://www.esdm.co.uk/configuring-certificates-for-azure-backup'>...</a>]]></description>
      <link>https://www.esdm.co.uk/configuring-certificates-for-azure-backup</link>
      <author>()</author>
      <comments>https://www.esdm.co.uk/configuring-certificates-for-azure-backup</comments>
      <guid isPermaLink="true">https://www.esdm.co.uk/configuring-certificates-for-azure-backup</guid>
      <pubDate>Sun, 15 Jun 2014 07:24:00 GMT</pubDate>
    </item>
    <item>
      <title>Backing up and restoring Azure VMs</title>
      <description><![CDATA[<p>&nbsp;</p>

<p>Note – none of the details below are required for simply creating and using VMs in Azure directly.&nbsp; The details come into play if you start ending to copy VHDs around and recreate VMs from them.</p>

<h1>Install Azure Powershell</h1>

<p>You need the command line Azure tools for PowerShell. Good description of getting started is here: <a href="http://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/" title="http://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/">http://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/</a></p>

<p>from here (download and install):</p>

<p><a href="http://go.microsoft.com/fwlink/p/?linkid=320376&amp;clcid=0x409" title="http://go.microsoft.com/fwlink/p/?linkid=320376&amp;clcid=0x409">http://go.microsoft.com/fwlink/p/?linkid=320376&amp;clcid=0x409</a></p>

<p>Will take a few minutes probably as it has a number of prerequisites that it may also have to fetch.&nbsp; I also installed Windows Azure powershell</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_101.png"><img alt="image" border="0" height="70" src="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_thumb_77.png" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" title="image" width="244" /></a></p>

<p>Eventually you will get a Windows Azure program folder and within that a Windows Azure Powershell shortcut</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_102.png"><img alt="image" border="0" height="93" src="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_thumb_78.png" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" title="image" width="244" /></a></p>

<h1>Connect to your subscription</h1>

<p>I used the certificate method described here: <a href="http://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/" title="http://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/">http://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/</a></p>

<ul>
	<li><strong>Get-AzurePublishSettingsFile </strong>(opens browser here you log onto your Azure account and it generates and downloads a file for publishing settings)</li>
	<li><strong>Import-AzurePublishSettingsFile&nbsp; "C:\Temp\Microsoft Partner Network-Windows Azure&nbsp; MSDN - Visual Studio Premium-6-11-2014-credentials.publishsettings"&nbsp; </strong>(Import subscription settings)</li>
</ul>

<h1>Accessing your VMs</h1>

<p>If all has gone well – <strong>Get-AzureVM</strong> should now list your VMs</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_103.png"><img alt="image" border="0" height="50" src="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_thumb_79.png" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" title="image" width="244" /></a></p>

<p>There are options for starting and stopping – but I’d just use the Azure web pages normally.</p>

<h1>Copying VHDs (Blobs) between storage accounts</h1>

<p>From: <a href="http://michaelwasham.com/windows-azure-powershell-reference-guide/copying-vhds-blobs-between-storage-accounts/" title="http://michaelwasham.com/windows-azure-powershell-reference-guide/copying-vhds-blobs-between-storage-accounts/">http://michaelwasham.com/windows-azure-powershell-reference-guide/copying-vhds-blobs-between-storage-accounts/</a></p>

<p>Michael gives a nice overview of how Azure storage is structured and some indicative timings as to how long copies may take (for 127GB VHD 12 minutes within data centre but cross stamp and 23 minutes between data centres (- I suspect this depends on where the datacentres are)</p>

<p>This command will complete quickly – but the copy will take a while to complete – so see section below on checking progress</p>

<div class="csharpcode">
<pre class="alt">
<span class="kwrd">Select</span>-AzureSubscription <span class="str">"Windows Azure  MSDN - Visual Studio Premium"</span> </pre>

<pre>

&nbsp;</pre>

<pre class="alt">
### Source VHD (West US) - authenticated container ###</pre>

<pre>
$srcUri = <span class="str">"https://<em>[StorageName]</em>.blob.core.windows.net/vhds/Test.vhd"</span> </pre>

<pre class="alt">

&nbsp;</pre>

<pre>
### Source Storage Account (West US) ###</pre>

<pre class="alt">
$srcStorageAccount = <em>[<span class="str">SourceAccountName]</span></em></pre>

<pre>
$srcStorageKey = <font color="#006080"><em>[SourceKey]</em></font></pre>

<pre class="alt">

&nbsp;</pre>

<pre>
### Target Storage Account (West US) ###</pre>

<pre class="alt">
$destStorageAccount = <span class="str"><em>[DestinationAccountName]</em></span></pre>

<pre>
$destStorageKey = <span class="str"><em>[DestinationKey]</em></span></pre>

<pre class="alt">

&nbsp;</pre>

<pre>
### Create the source storage account context ### </pre>

<pre class="alt">
$srcContext = <span class="kwrd">New</span>-AzureStorageContext  –StorageAccountName $srcStorageAccount `</pre>

<pre>
                                        -StorageAccountKey $srcStorageKey  </pre>

<pre class="alt">

&nbsp;</pre>

<pre>
### Create the destination storage account context ### </pre>

<pre class="alt">
$destContext = <span class="kwrd">New</span>-AzureStorageContext  –StorageAccountName $destStorageAccount `</pre>

<pre>
                                        -StorageAccountKey $destStorageKey  </pre>

<pre class="alt">

&nbsp;</pre>

<pre>
### Destination Container Name ### </pre>

<pre class="alt">
$containerName = <span class="str">"copiedvhds"</span></pre>

<pre>

&nbsp;</pre>

<pre class="alt">
### Create the container <span class="kwrd">on</span> the destination ### </pre>

<pre>
<span class="kwrd">New</span>-AzureStorageContainer -Name $containerName -Context $destContext </pre>

<pre class="alt">

&nbsp;</pre>

<pre>
### Start the asynchronous copy - specify the source authentication <span class="kwrd">with</span> -SrcContext ### </pre>

<pre class="alt">
$blob1 = Start-AzureStorageBlobCopy -srcUri $srcUri `</pre>

<pre>
                                    -SrcContext $srcContext `</pre>

<pre class="alt">
                                    -DestContainer $containerName `</pre>

<pre>
                                    -DestBlob <span class="str">"testD2.vhd"</span> `</pre>

<pre class="alt">
                                    -DestContext $destContext</pre>
</div>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>I get an error – but the command seems to complete OK</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_104.png"><img alt="image" border="0" height="85" src="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_thumb_80.png" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" title="image" width="244" /></a></p>

<h1>Checking the progress of a blob copy</h1>

<p>These can take a while – especially if between data centres – so its useful to be able to check how they are progressing.</p>

<p>$context = New-AzureStorageContext -StorageAccountName jamestestbackup –StorageAccountKey <em>[your key]</em></p>

<p>Get-AzureStorageBlob -Container "copiedvhds" -Context $context | Get-AzureStorageBlobCopyState</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_105.png"><img alt="image" border="0" height="82" src="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_thumb_81.png" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" title="image" width="244" /></a></p>

<h1>Stopping an asynchronous blob</h1>

<p>Copying blobs around can be tricky – especially if you are moving between accounts (and storage zones which makes things slow).</p>

<p>I managed to get some copies that seemed to appear in the destination – but were locked with a lease for a pending copy.&nbsp; I managed to sop these pending copies by:</p>

<p>Select-AzureSubscription -SubscriptionName "Your Subscription Name"</p>

<p>$context = New-AzureStorageContext -StorageAccountName jamestestbackup -StorageAccountKey <em>[your key]</em></p>

<p>Get-AzureStorageBlob -Container "copiedvhds" -Context $context| Stop-AzureStorageBlobCopy –Force</p>

<h1>Creating a new VM from a BLOB</h1>

<p>You can not do this until the copy is complete.&nbsp; The Azure interface seems to give no indication of when this is (see above for powershell script).&nbsp; If its not complete you will get an error about a lease being held (as the copy is still in progress) when you try and create the vhd</p>

<p>There are a couple of steps here:</p>

<p>1) You must use the VM, Disks section to create a VHD Disk from your BLOB (note your blob must have a .vhd file extension for you to be able to see it</p>

<p>2) Then you can create a new VM.&nbsp; Use the “From Gallery” option and you will see an option bottom left that allows you to pick your own disks</p>

<h1>Free tools</h1>

<p>This can be useful as an alternative interface for working with blobs</p>

<p><a href="http://www.cerebrata.com/download/azure-explorer" title="http://www.cerebrata.com/download/azure-explorer">http://www.cerebrata.com/download/azure-explorer</a></p>
<br /><a href='https://www.esdm.co.uk/backing-up-and-restoring-azure-vms'></a>&nbsp;&nbsp;<a href='https://www.esdm.co.uk/backing-up-and-restoring-azure-vms'>...</a>]]></description>
      <link>https://www.esdm.co.uk/backing-up-and-restoring-azure-vms</link>
      <author>()</author>
      <comments>https://www.esdm.co.uk/backing-up-and-restoring-azure-vms</comments>
      <guid isPermaLink="true">https://www.esdm.co.uk/backing-up-and-restoring-azure-vms</guid>
      <pubDate>Wed, 11 Jun 2014 16:18:00 GMT</pubDate>
    </item>
    <item>
      <title>Working with Azure storage</title>
      <description><![CDATA[<p>There are lots of ways using PowerShell to work with these – but they can be fiddly.&nbsp; However there is also a free tool: <a href="http://www.cerebrata.com/products/azure-explorer/introduction" title="http://www.cerebrata.com/products/azure-explorer/introduction">http://www.cerebrata.com/products/azure-explorer/introduction</a></p>

<p>This allows you to connect to your Azure storage and copy BLOBS (vhds) around and download locally if you want.</p>

<p>IMPORTANT: If you copy from one Azure storage to another – the copy comes via your desktop – so if files are big it needs to be on a fast connection!</p>

<h1>Connecting to your storage</h1>

<p>You need the name and key for the storage.&nbsp; This is available under your storage area in Azure.&nbsp; Pick your storage container and then at the bottom there is a “Manage Access Keys” option.&nbsp; You can use either primary or secondary key.</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_99.png"><img alt="image" border="0" height="244" src="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_thumb_75.png" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" title="image" width="229" /></a></p>

<p>&nbsp;</p>

<h1>Managing snapshots</h1>

<p>You can snapshot (or promote an old snapshot) using this tool</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_100.png"><img alt="image" border="0" height="165" src="https://www.esdm.co.uk/Data/Sites/1/media/wlw/image_thumb_76.png" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" title="image" width="244" /></a></p>

<h1>Downloading a vhd BLOB</h1>

<p>If you download a blob VHD – this can be mounted locally.</p>

<p>It works on Hyper-V 2012 and on Windows 8 but NOT on 2008 R2 (and presumably Hyper V and Windows 7)</p>
<br /><a href='https://www.esdm.co.uk/working-with-azure-storage'></a>&nbsp;&nbsp;<a href='https://www.esdm.co.uk/working-with-azure-storage'>...</a>]]></description>
      <link>https://www.esdm.co.uk/working-with-azure-storage</link>
      <author>()</author>
      <comments>https://www.esdm.co.uk/working-with-azure-storage</comments>
      <guid isPermaLink="true">https://www.esdm.co.uk/working-with-azure-storage</guid>
      <pubDate>Wed, 11 Jun 2014 12:42:00 GMT</pubDate>
    </item>
    <item>
      <title>Some jottings on SQL Azure and GIS</title>
      <description><![CDATA[<p>I have set up a SQL Azure 90 day trial (as of 18th November) to test whether ArcSquirrel can work with Azure. This was prompted by an email from Robert Cheetham, CEO at Azavea, who is investigating cloud solutions for their Cicero product. Here are some notes about</p>

<ol>
	<li>setting up and accessing SQL Azure databases</li>
	<li>using SQL Azure with ArcGIS + ArcSquirrel and MapLink</li>
	<li>using SQL Azure with Quantum GIS and MapServer.</li>
</ol>

<h4>Azure Management Portal</h4>

<p>Although I’ve never set up any cloud services before (other than <a href="http://www.arvixe.com/" target="_blank" title="Arvixe web site">Arvixe web hosting</a>) it was incredibly easy to setup a trial SQL Azure subscription (“Windows Azure Platform Introductory Special”), create a database, and add some firewall rules to control access. I didn’t dig deep, but the “Management Portal” seems nice and simple:</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_10.png"><img alt="Azure Management Portal" border="0" height="188" src="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_thumb_4.png" style="padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="Azure Management Portal" width="244" />&nbsp;</a></p>

<p>It helpfully tells you your connection string for ADO.Net, ODBC and PHP (passwords not included!):</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_8.png"><img alt="SQL Azure connection strings" border="0" height="180" src="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_thumb_3.png" style="padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="SQL Azure connection strings" width="244" />&nbsp;</a></p>

<p>See this page for <a href="http://www.microsoft.com/windowsazure/offers/popup/popup.aspx?lang=en&amp;locale=en-gb&amp;offer=ms-azr-0018p&amp;no-rewrite=true" target="_blank" title="Details of the Windows Azure Platform Introductory Special">details of the Windows Azure Platform Introductory Special</a> including what you get for no charge and the pricing for the rest.</p>

<h4>MapLink, ArcSquirrel and Azure</h4>

<p>Hartmut connected up our MapLink to the database and pushed some spatial data into my Azure database from ArcGIS – 20,000 polygons took about 75 minutes.&nbsp; Hartmut had the layers drawing in ArcMAP, performing as well as in a normal SQL Server instance apparently, with only minor mods to our code to make the initial connection. However editing will not work without some more tweaks - MapLink and ArcSquirrel rely on some SQL metadata that is a little different on Azure.</p>

<h4>SQL Server Management Studio and MS Access</h4>

<p>Connecting with SSMS is simple, however you get reduced functionality – for example you cannot right-click &gt; edit top 200 records or anything, so quick edits of a small table need to be done with SQL or in MS Access or some other client. Fortunately connecting with MS Access (ODBC + SQL Native Client 10) is also simple, and&nbsp; the Azure database behaves just like a local SQL instance – remarkable querying speed (all things considered), though slower inserts (10,000 records took something like 15 minutes). NB you cannot directly link a spatial table into Access because it doesn’t recognize the geometry data type; but to update attributes you can link a view.</p>

<p>Also, in SSMS you get no designer tools, e.g. for creating a view; everything has to be done with T-SQL.</p>

<h4>SQL Azure Database Manager</h4>

<p>After writing the above I found the database manager in the Azure control panel, which has functionality similar to SSMS, including the ability to edit the tables*:</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_12.png"><img alt="SQL Azure database manager" border="0" height="154" src="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_thumb_5.png" style="padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="SQL Azure database manager" width="244" />&nbsp;</a></p>

<p>* spatial data types not supported for view or edit.</p>

<p>You get a designer for creating/modifying tables, but views and stored procedures are T-SQL only.</p>

<h4>MapServer, OGR and Azure</h4>

<p>Next I wanted to try serving the data through MapServer, and viewing/editing the data in Quantum GIS or MapInfo.&nbsp; MapServer and QGIS require the “geometry_columns” and “spatial_ref_sys” tables, and the easiest way to create these is to push some data in with ogr2ogr.</p>

<p>So I tried this from one of our London servers. I loaded a few hundred linear features, but got four errors like “INSERT command for new feature failed… incorrect syntax…”. On checking the results, a) while the geometries had loaded fine, all the attribute fields were NULL, and b) the spatial_ref_sys table was empty.&nbsp; I had four attribute fields, so my guess is that each syntax error was one field update across all records using a join on the incoming data.</p>

<p>Next I hooked up a MapServer WMS to my SQL Azure tables. MapServer had no trouble connecting to my Azure tables, but initially wouldn’t draw anything…&nbsp; on investigating I found that ogr2ogr had not correctly set the SRID of the geometries, so I had to update them “manually” with:</p>

<pre class="csharpcode">
<span class="kwrd">update</span> esdm_waters <span class="kwrd">set</span> ogr_geometry.STSrid = 4326</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>(which, incidentally, took 1 minute 52 seconds for 788 rows, demonstrating that updating an Azure database ain’t quick).</p>

<p>Clearly OGR needs a little work to do on SQL Azure support, but this was enough to get me going.</p>

<p>The WMS worked, so to challenge it a little more I set up another WMS onto a table with about 8000 sub-tidal habitat polygons, showing red in this OpenLayers map:</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_2.png"><img alt="MapServer WMS from SQL Azure table" border="0" height="127" src="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_thumb.png" style="padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="MapServer WMS from SQL Azure table" width="244" />&nbsp;</a></p>

<p>And here showing the rivers WMS as well (blue lines):</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_4.png"><img alt="MapServer WMS from SQL Azure table" border="0" height="127" src="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_thumb_1.png" style="padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="MapServer WMS from SQL Azure table" width="244" />&nbsp;</a></p>

<p>Performance of these two layers was perfectly acceptable, though actually about 100% slower than the same WMS working from a local SQL Server 2008 Express instance. It would be interesting to see what it could do with MapServer also running on Azure.</p>

<p>I also tried a WFS – again, performance was acceptable though significantly slower than running with a local SQL instance (though I didn’t do strict comparisons).</p>

<h4>Quantum GIS and SQL Azure</h4>

<p>I found this really helpful blog post to get started: <a href="http://woostuff.wordpress.com/2011/03/13/opening-ms-sql-spatial-in-qgis/" title="http://woostuff.wordpress.com/2011/03/13/opening-ms-sql-spatial-in-qgis/">http://woostuff.wordpress.com/2011/03/13/opening-ms-sql-spatial-in-qgis/</a></p>

<p>Adding the layers requires some python script, but I’m sure someone will write a GUI plugin for QGIS soon.</p>

<p>First make sure you are running a version of QGIS that has GDAL/OGR 1.8 libraries – I’m on 1.7.0 which is OK.</p>

<p>Open the Plugins menu &gt; Python Console</p>

<p>and type in these two commands (modified for your data):</p>

<pre class="csharpcode">
uri = <span class="str">"MSSQL:server={serverName};database={databaseName};tables={tableName};trusted_connection=yes"</span>
qgis.utils.iface.addVectorLayer(uri,<span class="str">'{yourLayerNameHere}'</span>,<span class="str">'ogr'</span>)
</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>In my case:</p>

<pre class="csharpcode">
uri = <span class="str">"MSSQL:server=tcp:a0awtn7gg9.database.windows.net;database=ArcSquirrel1;tables=esdm_waters;Uid=exegesis@a0awtn7gg9;Pwd=myPassword;"</span>
qgis.utils.iface.addVectorLayer(uri,<span class="rem">'Rivers','ogr')</span>
</pre>

<pre class="csharpcode">
Without any fuss my rivers dataset appeared:</pre>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_14.png"><img alt="SQL Azure table in Quantum GIS" border="0" height="237" src="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_thumb_6.png" style="padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="SQL Azure table in Quantum GIS" width="244" />&nbsp;</a></p>

<p>And I can create and edit features and their attributes, here adding a test line off the Hebrides:</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_16.png"><img alt="Editing SQL Azure features in QGIS" border="0" height="237" src="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_thumb_7.png" style="padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="Editing SQL Azure features in QGIS" width="244" />&nbsp;</a></p>

<p>And to prove it, here’s my new feature in OpenLayers…</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_18.png"><img alt="Edited features from QGIS and SQL Azure" src="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_thumb_8.png" style="margin: 0px; width: 244px; height: 127px; padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="Edited features from QGIS and SQL Azure" />&nbsp;</a></p>

<p>And finally, here we have the habitat polygons (EPSG:27700) colour coded by habitat type, as well as the rivers (EPSG:4326), in QGIS. Polygon editing also worked fine, once I’d worked out why my new polygons kept vanishing (doh, classified symbols).</p>

<p><a href="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_20.png"><img alt="SQL Azure polygons thematically mapped in QGIS" border="0" height="237" src="https://www.esdm.co.uk/Data/Sites/1/Windows-Live-Writer/Some-jottings-on-SQL-Azure-and-GIS_5C47/image_thumb_9.png" style="padding-top: 0px; padding-right: 0px; padding-left: 0px; display: inline; background-image: none;" title="SQL Azure polygons thematically mapped in QGIS" width="244" />&nbsp;</a></p>

<p>Lots to think about, and I look forward to editing the same data with ArcGIS and ArcSquirrel soon…</p>
<br /><a href='https://www.esdm.co.uk/some-jottings-on-sql-azure-and-gis'>Crispin Flower</a>&nbsp;&nbsp;<a href='https://www.esdm.co.uk/some-jottings-on-sql-azure-and-gis'>...</a>]]></description>
      <link>https://www.esdm.co.uk/some-jottings-on-sql-azure-and-gis</link>
      <author>crispin.flower@idoxgroup.com (Crispin Flower)</author>
      <comments>https://www.esdm.co.uk/some-jottings-on-sql-azure-and-gis</comments>
      <guid isPermaLink="true">https://www.esdm.co.uk/some-jottings-on-sql-azure-and-gis</guid>
      <pubDate>Sat, 19 Nov 2011 11:42:00 GMT</pubDate>
    </item>
  </channel>
</rss>