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!
Paul Batum 5:14 pm on August 31, 2012 Permalink | Log in to Reply
Try require(‘request’) – this is how we make http available. We plan to expand what is available (‘azure’ was a particularly painful omission). Feedback on the available modules is very welcome!
Tony 3:53 am on September 11, 2012 Permalink | Log in to Reply
How about added rx.js.. that’s what I am talking about!