The Discussion

Adam Cooper

Really nice to see this support. Thanks for your work on this.

I have some questions about the JavaScript used on the server side. In your presentation you demonstrated that, for any Azure table, you can add custom logic for any of the four CRUD operations using JavaScript. Can you elaborate a bit more about this?

1) What is the development, debugging, and testing story? How do you develop and test the JavaScript? In the presentation your scripts were already prepared and simply pasted into the browser, but I'd like to know how you actually develop and test this script. Do you need to paste your script into the browser, save the web page, and then test the service? This seems cumbersome. Is there a way to get a faster feedback loop going when developing such a script? Must script updates be done via copy/paste? Can files be uploaded? Can files be uploaded from the console/command line? Can the service be tested locally without uploading to Azure?

2) What about code reuse? Can these scripts reference common JavaScript libraries or code?

3) Is JavaScript the only supported language for this? For those of us who are C# developers, can we define business logic via C# to be applied to an Azure mobile service?

I'm very new to Azure, so these questions may be answered elsewhere, but these were my first thoughts after watching your demo.

1. At the moment we see some developers working with their script directly within the UI while others write scripts in a separate editor and paste them in. We are working on a command line interface for Mobile Services which includes direct script upload - expect to hear more about this very soon.

When it comes to local testing, the most common pattern used at the moment is to extract as much of your logic as possible into a seperate object or set of functions and to unit test those. Unfortunately we do not have a local test environment or harness that you can use to test the entire script.

When it comes to debugging, you can use the console object to write to your logs which are available on the 'logs' tab in the portal. This is very useful when it comes to figuring out what is going wrong in a script.

2. There is a bunch of existing functionality that scripts can access using require(). We run scripts in node.js so standard node libraries like 'querystring', 'crypto', etc are all available for scripts to use. There are a few other libraries that we also make available - for example you can require('request') to get a great library for working with HTTP, and require('sendgrid') in order to send emails via the popular SendGrid service.

When it comes to reusing your own code, we recognize that we do not really enable this yet beyond copy/paste and we are actively working on addressing this issue.

3. JavaScript is the only supported server side language for Mobile Services right now, but that may change in the future. We have heard from a number of developers that they would like to be able to use C# instead as you suggested. I would encourage you to go to our user voice and vote for this if its important to you!