1

I have an Azure Web App running, which has custom Easy APIs defined and a few Easy Tables. I have been using this Azure Web App and the SQL tables connected to it to run a few javascript-based LOB Windows Store apps the past year and it has worked really well.

But now I need to access these resources for a Node.js process I'll be running locally. I'd like to access it in pretty much the same way I access it in my Windows Store app:

var client = new window.WindowsAzure.MobileServiceClient(
      "https://my-mobileservice.azure-mobile.net/",
      "MOBILESERVICEKEY"
);

If I can't access the Web App using the same API as provided above from within Node, it will suffice if I can just read and write rows to the SQL tables manually.

So how can I do this?

4
  • as such any mobile services api or any web api should be accessible via internet. so you should be able to consume them from the node js app that you have on premises. the same applies to the sql azure tables as well. for that of course you need to add firewall rule to allow traffic from the box where u run the node code. Commented Oct 23, 2016 at 17:58
  • @Aravind I'm not quite sure how I would use it in that way. That way of accessing it is, as far as I know, undocumented. Or at least I haven't seen that documentation. Commented Oct 23, 2016 at 21:09
  • @TKoL - what is undocumented? Easy Tables are just tables. Commented Oct 24, 2016 at 1:01
  • @DavidMakogon ok, I don't know how to access them. Commented Oct 24, 2016 at 9:37

1 Answer 1

1

The code snippet you provided was using Azure Mobile Apps client SDK, which is for devices or browsers.

In your other node.js application, you can consider to implement HTTP requests against your Easy Tables and Easy APIs scripts. As Azure Mobile Apps service has exposed them as RESTful APIs. You can refer to https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-node-backend-how-to-use-server-sdk/#TableOperations for more info.

And you can refer to the following code snippet for your information.

var request = require("request");
request({
    method:'GET',
    url:'https://<your_mobile_app>.azurewebsites.net/tables/TodoItem',
    headers:{
        'ZUMO-API-VERSION':'2.0.0'
    }
},(err,res,body)=>{
    console.log(body);
})
Sign up to request clarification or add additional context in comments.

7 Comments

Thanks Gary, I tried that and first I got this error: "This version (1.0.0) of the server does not support the use of the zumo-api-version in the request. For more information and supported clients see: go.microsoft.com/fwlink/?LinkID=690568#1.0.0" So I went to that URL and I couldn't really make heads or tails of what I was supposed to do with it, but I thought it was implied somewhere that I should remove the ZUMO header, so I removed the whole 'headers' section and then I got this error: "{"code":401,"error":"Error: Unauthorized"}" I'm so confused right now.
This means that your Mobile App is protected by an authentication provider. One of azure.microsoft.com/en-us/documentation/articles/…. So you need to authenticate in node.js application, get the token, and then set the token in headers. E.G. if you are using AAD to protect your Mobile App, you can leverage github.com/AzureAD/passport-azure-ad to apply the token.
@gary-liu-msft I'm sorry I'm so dense, I literally don't know where to start with that. I feel like using Azure was so easy when I was just making Universal Windows Store apps, and now it's so hard. When I look in my Azure Portal and find my App Service, I go to Authentication / Authorization and the setting for App Service Authentication is off. Maybe I'm overcomplicating this, so let me explain my end goal: I need to have a Node app running every 30 minutes which updates an SQL table connected to my App Service based on new information it's getting (from a Dynamics NAV source).
@gary-liu-msft I've considered maybe trying a node.js Web Job on my App Service, but even with that I can't find the documentation I need to tell me how I can access my Easy Tables from within the node WebJob
@gary-liu-msft So what I've done is this: I've created a new table on my Web App database, and I've left the permissions on the table as 'Anybody' for insert, update, delete and read. When I leave the permissions as 'Anybody', and remove your ZUMO-API header, I can apparently access the table quite easily. But it seems like this is not really a very security-conscious setting. My other tables have the permissions as 'Anybody with the Access Key'. Is there a way I can use the access key in Node.js to authenticate to the server?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.