Syringe.Net.Nz
Irregular Injection of Opinion
RSS 2.0|Atom 1.0|CDF

 Tuesday, July 20, 2010
Windows Azure Drives + SQL Compact 4 – Part #1

So there’s not a whole lots of stuff on the interweb that gets you started with drives and SQL Compact 4 is only just out into the open. My need was for a lightweight database for a sample app I’m building with Chris Klug for our session at Tech Ed New Zealand.

I thought I’d run quickly through how I got things going.

Getting the Bits
I grabbed the bits using the Microsoft Web Platform installer. I wanted two things. 1) SQL Compact 4 CTP1 and; 2) The Web Matrix tool.
It’s hopefully fairly obvious why I needed SQL Compact. The reason I wanted Web Matrix is because it’s currently the only tool I could find that will allow me to create and edit SQL Compact databases.

trznaj5k  ixuyzv04

I’ll be using Visual Studio for much of this post; I’m guessing y’all know how to get your mittens on that now.

Creating a Database
To build our database we’ll be using Web Matrix. It doesn’t have a specific database designer that is independent of the site editor so we’ll need to create a site and then create it in the context of our site.

mdhkuthy
We’ll start from a template.

sepojgnz
…and create an empty site.

Choose Databases from the left hand nav.

p2py5yin

Choose to create a new database from the ribbon

1cx4dml5

Double click to select tables. And right click to add a new table

a5kbmcaw

Create a basic table definition with a ContactID and ContactName. Use the Ribbon controls to create new columns. Use a BigInt identity column for the ID and make it the Primary Key.

ih4vdprv

Save the table as Contact

Close Web Matrix- our database has been created and saved into a subfolder of my documents. Mine was at

C:\Users\Chris Auld\Documents\My Web Sites\Empty Site\App_Data

We need some data in our database. We could ahve used Web Matrix to do this but I wanted to show another tool that allows us to execute raw SQL against the DB as it may be more suited to some developers.

The tool in question is the SQL CE Toolbox (you’ll need the latest version which is a standalone application)
Grab it from here: http://sqlcetoolbox.codeplex.com/
Don’t just install the VIsual Studio add-in version as at the time of writing it doesn’t support the v4 sdf format.

Open the tool and right click to add a new connection

wgaqiuot

Open the database file and test the connection

ztpigimk

Expand the tree to show our Contact table. Right click and choose ‘Script as Insert’. This will create a template insert script for us.
Enter some sensible (or stupid if you prefer) values and then execute the query. I didn’t attempt to insert the identity column and so removed that from the query.

slfl4yrk

Before we leave this tool click the Estimated Plan toolbar button. As long as you have SQL Server Management Studio installed it’ll open that tool and hand over the query plan text.

43uma5oy
That’s right folks. That is a graphical query plan graph of the query for my embedded database. That’s pretty damn cool!

Getting Your Database Into Windows Azure Storage

Being a database we want our *.sdf file sitting in a WIndows Azure drive. There are a bunch of ways we could do this:

- We could put it into our service package, create a drive on startup, copy to the drive and then do a lazy check each time we start so it’s only done once.
-We could create the whole VHD on the client machine and upload that to storage. This removes any of the once only init code from our application. THis is the approach I chose to use

We need to create a VHD. Hooray for Windows 7- this is trivial. If you are a hard-ass like Steve Marx then you can use a batch command to do this but you all know that I’m not really a hard ass so I’ll do the draggy droppy clicky clicky thing.

Open Disk Management. I’m a fan of the search box in the start menu- type ‘Disk Management’ and then select ‘Create and format hard disk partitions’

ll3azfwj

Use the Action menu to Create VHD. Stick it somewhere useful like the desktop as we’ll need to grab it later. You’ll want to choose a fixed size- I chose to make it 100MB. You’ll only pay for the actual data you store on disk (not the empty stuff) but more on that shortly.

soyitaae

Once created you’ll need to Initialize the disk with an MBR

mhcwels0

.. and Format as NTFS

0bubf4tl

image\

The drive will now be available in Windows Explorer and we can copy our *.sdf file across from the My Web Sites directory to our new VHD

Once we’ve copied it over we can go back and Detach the VHD

hg2c3kjm

Now we can upload the VHD to Blob storage. Before you crack out your favourite Azure storage client (I like Cloud Studio from Cerebrata) you’ll need to want to check that it supports sparse Page Blob uploads. Cloud Studio doesn’t so we’ll use the VHDUpload Tool from here: http://blogs.msdn.com/b/windowsazurestorage/archive/2010/04/11/using-windows-azure-page-blobs-and-how-to-efficiently-upload-and-download-page-blobs.aspx I took the liberty of building the tool: VHDUpload

image

 

More in the Part 2 of this post tomorrow.

Windows Azure|Tuesday, July 20, 2010 8:24:02 AM UTC|Comments [0]|    

 Monday, May 03, 2010
Windows Azure Certificates for Self management Scenarios

The Windows Azure Management API uses x509 certificates to authenticate callers. In order to make a call to the API you need to have a certificate with both public and private key at the client and and the public key uploaded into the Azure portal. But, if you then want to call the management API from your Windows Azure VMs then you’ll also need to install the cert into the instances by defining them in the service definition This post will show you how.

I found it a bit of a pain to get going so here’s my simple guide. I used this to setup the certs for my favourite open source Azure toolkit Lokad-Cloud. We’ll be creating a self signed certificate, then uploading that certificate into the Windows Azure management portal. Finally we’ll add the certificate to our service model to ensure that Windows Azure installs the certificate into our VM instance when it is started.

Here’s the approach in pictures so you can follow along.

  1. Create a self signed certificate in the IIS7 Manager
    Open IIS7 Manager
    image 
  2. Expand the node for your local machine
    image 
  3. Double Click Server Certificates
    image
  4. Choose Create Self-Signed Certificate
    image
  5. Give it a friendly name
    image

You’re all done in IIS7 Manager. It’s just created a new Certificate and added this into the trusted root certification authorities on your machine. This is a highly trusted location for the cert so do be careful if you ever export it with the private key included.

We need to export it with the public key included so that we can upload it to the Windows Azure Portal.

  1. Run CertMgr.msc - just type it in full into the Start box.
    image
  2. Expand 'Trusted Root Certificates Authorities –> Certificates"’
    image
  3. Find your cert using the friendly name column and right click and choose Export
    image
  4. Choose the option to NOT export the public key. You should generally avoid exporting the public key if at all possible*.
  5. Choose to export as a DER Encoded binary
  6. Save it somewhere useful – we stick ours into source control
  7. Choose Export again, but, this time choose to export the private key
    Leave the PFX options all unchecked
    image
  8. Give it a sensible name.

You’re all done exporting. Now we need to upload it to Azure.

  1. Go to the Windows Azure Portal
  2. Choose the appropriate project
    image
  3. Click the Account tab across the top of the page
    image
  4. Click Manage My API Certificates
    image
  5. Browse to and upload your *.cer file you created earlier
    image
  6. You should now see the certificate listed against the account.
    Note that it’ll be listed using the Subject rather than the friendly name. So you’ll need to identify it by the thumbprint if you have multiple uploaded from the same machine. Azure Team: Can we please have the friendly name listed here?
    image

Now we’re ready to use our certificate from the Windows Azure Tools for Visual Studio

  1. Open your Windows Azure Project – We’re using Lokad-Cloud here
  2. Expand the Cloud Project to show the Roles.
    image
  3. Right click the Web Role and choose properties
    image
    This will open the Snazzy Windows Azure graphical UI. This is much nice than editing the Model XML by hand.
  4. Choose the Certificates Tab
    image
  5. In our case there is already a certificate entry defined by the default Lokad Model definition.
    Click the elipses (…) at the end of the thumbnail column to open the certificate chooser dialog.
    image
  6. Choose the cert from the dialog
    image
  7. Repeat for the worker role

The last thing we need to do is upload the certificate into our cloud service before we can upload our packages.

  1. Create a new Cloud Service
  2. Browse to the bottom of the page to find certificates and choose Manage
    image
  3. Browse for your certificate (including the private key)
  4. Punch in your password and hit upload
  5. Confirm that you’re all uploaded.
    image

You’re all done. Now you can happily deploy the app to Windows Azure along with having your certificate deployed into your Azure instances as well. This means that your Azure roles can now call the management API themselves.

*There will be times when you need to export the public key. We’ve had to do that in this scenario as we actually want to install the private key into our Azure instances. Another good example here is in a shared development environment. You have the option of either sharing a certificate among everyone or each uploading your own public key. Because we’re using the lokad tool and this explicitly supports just a single cert we’ve actually exported our cert (password protected) into our source control system so all developers can install the same private key.

If you have done an export and want to install the private cert onto a new machine then you’ll need to add it into the Local Computer –> Personal store.

  1. Run MMC by typing MMC in the start run box
  2. Add the Certificates Snapin
    image
    image
  3. Choose Computer Account
    image
  4. Choose local computer
  5. Open the Personal Store and choose More Actions>Import
    image
  6. Browse to and import your certificate.

The certificate should now be visible in the Windows Azure Tools for VS.NET cert selector dialog.

Windows Azure|Monday, May 03, 2010 9:18:56 AM UTC|Comments [0]|    

 Tuesday, April 20, 2010
Windows Azure Pricing Calculator Spreadsheet

I’ve mentioned this at a heap of sessions I’ve presented at and have never managed to get around to posting it.

So. Attached is my Windows Azure Pricing spreadsheet.

Pretty simple. has three worksheets.

  1. A simple Table storage calculator that determines the cost of table storage.
    This includes overhead calculation – i.e. what is the ration of name to value in your name/value pairs
    It also checks your key lengths fall within the 260 char URI limit and a few other things.
  2. A model of session state pricing.
    Basically shows that SQL Azure will typically be a cheaper option for Session state storage (or anything with little data on disk and high read/write counts).
  3. A detailed (very detailed) model of PhluffyPhotos.

For more detail please see my MIX10 session on Storage in Windows Azure Platform

http://live.visitmix.com/MIX10/Sessions/EX11

Windows Azure|Tuesday, April 20, 2010 9:06:10 PM UTC|Comments [0]|    

 Thursday, January 07, 2010
Chris and Dave do Denniston

Denniston is a former coal mining area situated on an alpine plateau about 30km North of Westport on the West Coast of New Zealand (Wikipedia here). It was actually an active mining area right up until the 1960’s. In recent years it has fallen under the ambit of the Department of Conservation. Along with the Buller Cycling club they have been building out a bunch of Mountain Bike tracks around the area.

You can pull details on the cycling area from the DoC site and from the Buller Cycling club.
http://www.doc.govt.nz/parks-and-recreation/places-to-visit/west-coast/buller-area/denniston/activities/mountain-bike-tracks/ 
http://www.cyclebuller.co.nz/index.php?option=com_content&view=category&layout=blog&id=19&Itemid=3 

Dave and I decided we’d try and visit the tracks as part of our summer South Island road trip. We drove in via Murchison as we did some paddling along the way. We had a couple of days in the Murchison region where the water levels were well up. Paddled a few runs that I’ve done before as well as a new run down the mangles that started with about a 2m waterfall- pulled quite a crowd when we ran that one for some reason… didn’t seem that difficult.
The crew on the Middle Matakitaki river Whitewater shuttles of doom.

We drove into Westport the evening before we planned to ride and found ourselves a nice motel (Buller Bridge Motel) with free WiFi. Got up early and headed up the hill. This place really is quite the plateau. The hill rises steeply off the ocean almost to an altitude of about 650m at the carpark. The views were pretty good for us; on a really fine and still day I can imagine you’d be able to see all the way up to Karamea.

Once we got to the top we had a bit of a potter around looking at some of the old mining ruins. Denniston is famous for the Denniston Incline which is a frighteningly steep, two pitch, coal railway that literally goes straight up the side of the hill. Check out this video from the NZ Archives for an idea of what it was like.

Below the carpark. Looking down to the incline top loading yard. Walking among the wagons in the loading yard Looking down the incline!

Then we headed up the hill to the Museum Car park which is the designated starting place for the Mountain Biking trails. While getting organized we saw the Google Car driving around- yes, even in the middle of bloody nowhere there is Google!

Getting organized at the museum Google car. Ho9pefully we'll be able to see ourselves!

We started out with the Ropers Hotel Circuit.
http://www.cyclebuller.co.nz/attachments/011_MTB%20-%20Denniston%20-%20Ropers%20Hotel%20Circuit.pdf 
Straight away the riding was quite different to anything we’d ridden before in New Zealand. Lots of slick rock and ledges. Was quite fast riding and reasonably hard on the suspension. A 6” trail bike is ideal- we had a Trance and a Mojo. The last part of this track before it hits the road is walking only- for ecological reasons rather than ride-ability. You definitely want to do this track in the predominant direction indicated on the map as it would be a pain to walk up that hill.

Next we rode out on one of the longer trails. This was nominally on 4WD track but I’d challenge most people to take their 4WD there and get it back in one piece. The track was Sullivans Circuit and it went off the other side of the Plateau back down towards Westport.
http://www.cyclebuller.co.nz/attachments/011_MTB%20-%20Denniston%20-%20Sullivans%20Circuit.pdf 

Looking up towards Mt Rochfort More ruins. We think the top of the old aerial ropeway 
P1062415P1062416

This track had plenty of challenging riding. Lots of large rocks and ledges. it was all too easy to go far faster than 0.1mm of lycra really should justify.

P1062417 P1062422 Just a little off

Finally we rode the Miners and Drill track circuits. Again, lots of hairy riding with a bunch of sketchy single track, some of which we both had to walk.

Gratuitous Bike Porn Riding the Slick Rock Self Porttrait

There was still plenty of sign of the old coal mining stuff and indeed the coal itself.

Coal mine fire Coal seam

Despite only doing about 30km (in 3.15hr!) we were in need of a beer once we got back to the car.

Post ride beer time Some amazing Rata trees on West Coast. This is a small one!

Here’s the GPS dump

image

And the full TCX file of my Garmin 310XT is here:
http://connect.garmin.com/activity/21786909

Adventure Sports | Gettin Fit|Thursday, January 07, 2010 5:42:29 PM UTC|Comments [0]|    

 Friday, January 01, 2010
Interesting Stats from 2009

Thought it would be interesting to do a blog post of my stats for 2009.

It was a pretty hellish year for travel. It’s the first full year that I’ve used TripIt which has proved to be a really useful tool. TripIt also provides travel stats.
image

Now not all of this was work travel (I had a couple of overseas holidays) but it was still a pretty full on year.

This is borne out in my exercise stats. Obviously my most exercised location was Wellington, but, I also did a whole heap in Issaquah, Washington and also in Bangalore, India.

Num. activities - Location

I remained pretty steady over the course of the year in terms of the amount of exercise I did. It was still really hard to maintain anything approaching a good training program though.

image

Once again it was a shitty year for me skiing wise, though these stats do miss out a bit of skiing I had in January. I also did far less mountain biking than I would have liked to.

Time - Category

I did do over 300hr of exercise over the year and travelled 2700km. I also burned 65,000 calories.

Will be interesting to see what I can manage this year.

Adventure Sports | Gettin Fit|Friday, January 01, 2010 3:42:44 AM UTC|Comments [0]|    

 Wednesday, October 21, 2009
Microsoft Office Extensions to the Open XML File Format (ISO29500) Specification

So the question was asked today in my Open XML Development for Office 2010 and beyond as to whether the Word 2010 Extensions documentation was available anywhere.

I had to take an action item to follow up and find this.

It can be found here: http://msdn.microsoft.com/en-us/library/dd773189.aspx

Office2010 | SPC09|Wednesday, October 21, 2009 11:37:28 PM UTC|Comments [1]|    

 Monday, October 19, 2009
My Hopeless Gym Experience at the Mandalay Bay Spa

So… I genuinely object to paying US$20/day to use the hotel gym. But, needs must sometimes and so it was that I found myself at the Mandalay Bay Spa  $20 the poorer this morning. Been working reasonably hard in the build up to the K1 road race in a couple of weeks so needed to get some time in on the stationary trainer.

Well, what an utterly useless experience that was. I got inside the Gym to find that;

  1. They had two consumer grade exercycles and that was it as far as bikes went.
  2. None of the cardio equipment was available anyway

So even if I had been able to get on the equipment it wouldn’t have been much good for the Interval workout I had planned- I ripped the crank off a consumer grade exercycle in Bangalore this year so it’s just downright dangerous.

In the end I threw my toys out of the cot, got myself a refund of my fees and went for a run up the strip.

image 

Think I’ll try and find someone friendly at the Luxor for the Gym tomorrow and will not be staying at the Mandalay Bay for MIX10 next year that’s for sure.

Gettin Fit | SPC09 | Travel|Monday, October 19, 2009 2:43:18 PM UTC|Comments [4]|    

 Tuesday, September 22, 2009
Smashed a new PB on my hill repeat ride

Got out for hills this morning on the road bike. Turned into a shorter ride, but, I pushed the 2nd interval really hard (100% MHR) and in doing so smashed about 7% off my PB up the short pinch climb I do.

image 

The average power was 450 Watts over the 4min 31 seconds. Pity the hill wasn’t a touch longer as it meant my new PB 5 minute power ended up being only 431 Watts i.e. 30 seconds of my rest break at the top was included.. Goal for the next few weeks is to really work on lifting my power profile. I think I’ll probably look at doing Peak 1’w and 5’w on Happy Valley road as it certainly appears to help going up a hill. At the moment my 1’w isn’t even on the chart and I’d like to work on getting my entire profile into the Cat 4 region over the next few weeks in the lead up to the K1 race. Means I need to be targeting 350 Watts for 60 minutes which I think is going to be the hardest bit.

image  image

The other interesting thing is to see just how much temperature variation affects my (supposedly temperature compensating) barometric altimeter on the Polar s625x. All 5 of those intervals should be the same height, but, there is a definite trend downward over the set.

Adventure Sports | Gettin Fit|Tuesday, September 22, 2009 8:16:12 PM UTC|Comments [0]|