0
votes

I'm playing around with a webjob on my Azure platform and decided Id take a challenge and write it in JS.

I have essentially everything talking to an Azure Easy Tables that the app i'm writing relies upon - EXCEPT - I decided I wanted the server (Azure) to do some of the API info grabbing and deposit it straight into the tables for me.

So far I can get a jsdom environment to talk to Azure but the user agent I think is kicking the Mobile client out.

jsdom.env({
html: "<!DOCTYPE html><html><head></head><body></body></html>",
headers: { 'User-Agent': 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)' },
done: function (errors, window) {
var $ = require("jquery")(window);

console.log('Kebab');
console.log(window.navigator.userAgent);
console.log('Lettuce?');

var client = new WindowsAzure.MobileServiceClient('https://myapp.azurewebsites.net');
var locationTable = client.getTable('table').read().then(
  function (events) {
    console.log(events);
  },
  function (events) {
    console.log(events);
  }
 );

console.log('Chilli?');
console.log(client);
window.close();
}
});

The window.navigator.userAgent reports:

Node.js (win32; U; rv:v6.7.0) AppleWebKit/537.36 (KHTML, like Gecko)

Azure connection to the table gives me this:

Error: Unsupported browser - no suitable providers are available.

Which when searched for implies that its triggering the Azure fail as it cant see any browser that will allow it to work.

I know it's got as far as the Azure platform as the console.log(client) responds with the installation ID.

So is it jsdom? Azure client needs tweaking to allow this through? A better way using the tools I have to do this (has to be Easy Tables etc).

1

1 Answers

0
votes

Unfortunately, the MobileServiceClient JS library doesn't work in a Node environment right now. (Feel free to log a feature request on our github repo).

As a workaround, you will need to do a direct HTTP connection, requesting /tables/ with the right headers (most notably, ZUMO-API-VERSION=2.0.0)