Azure Mobile Services = Node.js

The new Mobile Services preview in Windows Azure provides developers with a database and API to store data for a mobile application. You can hook in your own custom code, to perform validation or send messages, etc… for each of the CRUD operations on an entity. The code is JavaScript, which seem to be hosted by a Node.js process. A small amount of playing around revealed that you can use the ‘require’ function to load in some of the standard node modules.

Available Modules

Access is not provided to all node modules, but these are available:

  • events
  • util
  • crypto
  • string_decoder
  • path
  • dns
  • url
  • punycode
  • readline
  • assert
  • zlib
  • azure

These module are not:

  • azure
  • tls
  • os
  • fs
  • dgram
  • http
  • https
  • repl
  • vm
  • child_process
  • tty
  • cluster

The ‘process’ variable is not available either.

Logging

If you write to the console, your message will appear in the log! (see the source code above):

Arguments

The objects that get passed to your function look like this:

item = { text: 'A VALUE', complete: false } // this will depend on your model
user = { level: 'anonymous' }
request = { operation: 'insert', parameters: {}, execute: [Function], respond: [Function] }
this = null

Conclusion

Whether anything really interesting can be done with this limited set of modules remains to be seen, but I’m really pleased to see that node is being used. Time for a bit more playing!

About these ads