Monthly Archives: October 2014

Upgrading from azure sdk for nodejs from 0.6.x to 0.10.0

Published October 28, 2014 4:45 pm

Our (under development) backend service is a nodejs service and uses azure sdk for nodejs to use azure storage. I found breaking changes recently and put on hold upgrade to latest azure sdk. Last week, I have taken up the work to integrate with the api changes between 0.6.x to 0.10 of azure nodejs sdk.

Our usage is is primarily around azure storage and especially apis for azure table and blob storage. I came across following changes:

  1. azure module has been divided into smaller modules and it is the aggregator module. It is possible to take dependency on smaller modules like azure-storage. I have not yet done that. That is remove dependency from azure and only take dependency on azure-storage.
  2. Not related to azuresdk; npm has also changed somewhere in between and now, it does not print modules it is downloading on the console. I liked it to printing friendly http gets on the console rather than simple rotating pipe (|) without any other information. In my opinion, status reporting degraded for npm install command.
  3. Type information is added to entity properties in entity descriptor (ed) parameter across all APIs. This is a big change. I have to take care of this at lot of places in code. Details later.
  4. tableService.queryEntity has been renamed to tableService.retrieveEntity
  5. tableService.queryEntities parameters has changed. Two new parameters – tableName and continuationToken
  6. blobService.listContainers has been renamed to blobService.listContainersSegmented and takes additional continuationToken parameter
  7. blobService.getBlobUrl renamed to blobService.getUrl and last parameter has changed from accessPolicy to sasToken. It has to be obtained by invoking blobClient.generateSharedAccessSignature() method.
  8. TableQuery has to be instantiated and not used as singleton. It does not encapsulate table name and hence, table name has to be passed separately to tableService.queryEntities method. from() call needs to be removed from the call chain building the table query.
  9. tableQuery.whereKeys is removed.  .where has to be used with filter as ‘ParitionKey == ? and RowKey == ?’
  10. filter string can have ‘?string?’ or ‘int32’ etc. in place of ? to accommodate typed arguments.
  11. queryEntities will only return one set of results. continuation needs to be handled by client. Earlier it was handling it.
  12. blobService.setContainerAcl – parameters have changed. it takes signedIdentifiers array directly (instead of a property in options) and extra publicAccessLevel parameter.
  13. tableService.beginBatch/commitBatch has been replaced by new class TableBatch and tableService.executeBatch method.
  14. tableService.createTableIfNotExists returns statusCode 200 if table already exists

A good number of breaking changes to keep one busy for couple of days to upgrade. Some of the changes are minor. Some require time to grasp and then, make the change.

Earlier, all entity properties where direct property on the ed object and used java script types. Now, it has its own typing and all of them look like “object” to javascript. Each such object has two properties: _ is the value and $ is the type name. It provides azureStorage.TableUtilities.entityGenerator to generate such objects.

// insert/update entity
// entityGenerator helper can be used to build entity descriptor when inserting or updating an entity
var entGen = require('azure-storage').TableUtilities.entityGenerator;
var myEd = {
    property1: entGen.String('hi'),
    property2: entGen.Int32(2),
tableService.insertEntity('mytable', myEd, ...);

// querying entities
var myQuery = new TableQuery().select().where('PartitionKey == ?', pk);
// var myQuery = new TableQuery().select().where('PartitionKey == ?string?', pk);
tableService.queryEntities('mytable', myQuery, null /*continuation token*/, onqueryentities);
function onqueryentities(e, r, response)
    // result r:
    // earlier: array of entities
    // now: object. { entries: array, continuationToken: ..}
    var entity = r.entries[0];
    // access entity.property1
    // earlier: entity.property1
    // now: entity.property1._
    var p = entity.property1._;

Were you also using azure nodejs sdk older version? How was your upgrade?