Friday, March 22, 2013

Upgrading Azure Storage Client Library from 1.7 to 2.0

I recently needed to update a Windows Azure customer project to use the current version of Azure Storage Client library. Luckily NuGet automates most of the package management activities (adding references, dependencies etc). Apparently there have been some dramatic changes in the structure of the library itself, since I had to do quite a lot of work to bring the code back up to working level.

Some issues I bumped into:

Microsoft.WindowsAzure.StorageClient namespace has been renamed to Microsoft.WindowsAzure.Storage

CloudStorageAccount.SetConfigurationSettingPublisher() is no longer supported, use CloudConfigurationManager.GetSetting() instead. Typically like this:

Account = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting(configurationSettingName));

StorageClientException class renamed to StorageException, notably the following code:

catch (StorageClientException ex)
{
    if ((int)ex.StatusCode == 404)
    {
        return false;
    }

    throw;
}

becomes:

catch (StorageException ex)
{
    if ((int)ex.RequestInformation.HttpStatusCode == 404)
    {
        return false;
    }

    throw;
}

Uploading/downloading blobs only support streams instead of the earlier options that included byte array, string etc.

So instead of this code:

public void SaveImage(string containerName, string blobName, string contentType, byte[] data)
{
    CloudBlobContainer container = BlobClient.GetContainerReference(containerName);
    CloudBlob blob = container.GetBlobReference(blobName);
    blob.Properties.ContentType = contentType;
    blob.UploadByteArray(data);
}

you need to do something like this:

public void SaveImage(string containerName, string blobName, string contentType, byte[] data)
{
    CloudBlobContainer container = BlobClient.GetContainerReference(containerName);
    ICloudBlob blob = container.GetBlockBlobReference(blobName);
    blob.Properties.ContentType = contentType;
    var blockBlob = blob as CloudBlockBlob;
    using (var stream = new MemoryStream(data, writable: false))
    {
        blockBlob.UploadFromStream(stream);
    }
}

Note the use of GetBlockBlobReference() method instead of GetBlobReferenceFromServer() in the new code. The latter actually hits the server (thus resulting in performance hit), but what’s more crucial is that it actually fails if the blob does not exist. So if you need to create a new blob, it cannot be used at all, so most likely you will end up using GetBlockBlobReference() instead.

Retry policy structure has changed. Instead of this:

BlobClient.RetryPolicy = RetryPolicies.Retry(4, TimeSpan.Zero);

you need to do something like this:

using Microsoft.WindowsAzure.Storage.RetryPolicies;

BlobClient.RetryPolicy = new LinearRetry(TimeSpan.Zero, 4);

Links

Monday, March 18, 2013

Lenovo IdeaPad Yoga 13 first impressions

General

I picked up Yoga 13 from a local hardware store a few days back. It is the best equipped version with Intel i7, 256GB SSD and 8GB ram. See my post on why I ended up with Yoga instead of Twist or Helix here if you are interested.
I wanted the one with as much as possible storage capacity, since it will be used by everyone in my family and each of us have some stuff in Skydrive etc so 128GB version seemed a bit small. However, it seems to be possible to upgrade the SSD but the price difference seemed to make it worth to begin with the larger option. The drive has a lot of partitions on it, which probably not all are useful. I will probably wipe the drive at some point and do a fresh install of Win8, but let’s see when I have the time to do that.
In general Yoga seems like an impressive piece of hardware. Build quality seems very good and the 1600x900 IPS screen looks marvelous. The kids also love it and one of the first things I did was to configure a suitable maximum amount of time per day for them to reserve at least some slices of time for me as well Smile

Yoga as an ultrabook

Yoga is a pretty slick package for a 13,3” laptop, it I fairly light and thin but yet rather solidly built machine. Having used to traditional ThinkPad line of Lenovos in the past, there are two notable differences you need to be aware of.
First, the keyboard is nowhere near the touch and feel of, say, T420 that is my everyday software development machine. The keys have very small amount of movement and thus they feel a bit numb. Also the keyboard layout is a bit different which takes some getting used to. However, this seems to be the norm in all laptops the size of an ultrabook nowadays so you need to sacrifice something to get that thin outlook.
Second, Yoga does NOT have a TrackPoint mouse (that integrated red stick between GHB keys), only a TouchPad as all other ultrabooks on the planet. Oh well, another compromise…

Yoga as a tablet

Yoga can be used as a tablet as well. The screen turns 360 degrees behind the keyboard (or you can turn it halfway into “tent” or “stand” mode). It feels a bit odd at first that you feel the keyboard on the back of the “tablet”, but you get used to it. No worries, the keyboard is disabled in this mode and there are no accidental key presses.
It has happened a few times that in the tablet mode the screen orientation (portrait/landscape) sensor has not worked correctly and I had to put it in sleep and wake it to recognize orientation changes. 98% of the time it seems to work correctly but there may be some driver issues or some other problem that causes that. Update: I know about the screen orientation lock button, it was not activated.
I have found myself using the tablet almost always in landscape orientation. It feels very tall in portrait orientation due to the 16:9 screen. Reading a long text is the only exception, that seems to be ok in portrait orientation.

Summary

Yoga 13 is a fantastic device! The build quality is very good and the idea of different modes (laptop/tablet/tent/stand) is surprisingly natural. It is our family’s favorite PC from now on!

Wednesday, March 13, 2013

Lenovo Yoga, Twist or Helix?

I have been looking around for a new laptop/tablet/touch machine for a few months now, and finally there are some options that are actually shipping. I am a long-time ThinkPad person so I am primarily looking for Lenovo although I know there are other options as well.

Primary use in my case would be:

  • All-around web surfing at home and on the road (vacations etc) for family use
  • Occasional photo editing with Lightroom (I have a separate machine with calibrated display for the serious stuff)
  • Testing of touch-enabled Windows 8 apps that I have implemented
  • Occasional software development with Visual Studio (again, separate dedicated machine for serious stuff)

Due to my requirement to run traditional desktop software, an RT machine will not do. Therefore I am looking at hardware that runs Windows 8 Pro. The pros and cons listed below reflect my priorities and my personal opinions, of course. YMMV.

The options

All of the options below share similar characteristics: i7, 8GB of RAM, an SSD (size varies), around 1,5kg weight and a touch screen that can also be used as a tablet. I have personally test driven both Yoga and Twist briefly, but Helix is so new that I haven’t been able to get my hands on one yet.

IdeaPad Yoga 13

Yoga is a new design that I haven’t seen before. The screen flips over 360 degrees so that it can be used as a tablet. Drawback is that the keyboard is left exposed in tablet mode.

Pros

  • sturdy hinge, good overall build quality
  • 256GB SSD
  • decent screen resolution (1600x900)

Cons

  • no built-in 3G
  • new type of charger connector (I have a bunch of Lenovo chargers
  • no TrackPoint mouse, only a TouchPad (rare for Lenovos)
  • somewhat closed construction (no user replaceable SSD etc, but makes it sturdier of course)

Yoga 13 tech specs from Lenovo site

ThinkPad Twist

Twist has a familiar design from earlier ThinkPad X…T line of convertible tablets.

Pros

  • 3G
  • traditional round ThinkPad charger connector (matters to me because I have compatible chargers lying around)
  • SSD can be replaced easily
  • TrackPoint mouse

Cons

  • low screen resolution (1366x768)
  • glossy screen & surrounding plastics
  • build quality not high enough for my taste (plastics everywhere)

tech specs from Lenovo site

ThinkPad Helix

Helix is the only one I haven’t been able to try out personally, but based on what I have read from the internet, Helix seems to be by far the best device in the group. However, it is also by far the most expensive one and it remains to be seen how well the detachable screen construction works in practice and how durable the hinge mechanism is. If the build quality is excellent and e.g. fan construction proves to be good, then the higher price might be justified.

Drawback of the detachable screen is that all of the electronics has to be packaged to the screen part. That makes the screen+keyboard combo probably a bit top-heavy, although in Lenovo’s design the weight is almost evenly distributed since the keyboard has additional battery – a nice way to extend the battery life.

Pros

  • detachable screen that makes this a lightweight tablet
  • 3G
  • excellent screen resolution (1920x1080)
  • digitizer, pen for precision touch

Cons

  • expensive (about 1000€ more than Twist & Yoga 13 based on preliminary pricing)
  • new construction, durability

 

Summary

I ended up purchasing the Yoga. The lack of 3G is compensated by sharing my Lumia’s network connection and I will just need to either use external mouse or learn to use the TouchPad mouse.