0

I have followed a tutorial to write a script on Azure for a custom SQL to retrieve some data: https://www.tapanila.net/windows-azure-mobile-services-custom-api-for-existing-sql-database/

Im working on a mobile service, and use "Easy API" on Azure.

I get an error when I write this script:

exports.get = function(request, response) {
    request.service.mssql.query(
        'select * from varegrupper', {
        success: function(results) {
            response.send(200, results);
        }
    });
};

This is my error:

{"error":"Cannot read property 'mssql' of undefined"}

Any idea what I have missed?

2 Answers 2

3

There is a significant difference between Mobile Services (now deprecated) and Mobile Apps. The API you're trying to work with is the Mobile Services API, where you are using Mobile Apps. You can find a sample project with a custom API that executes SQL statements here. You can also find some reference documentation here.

Sign up to request clarification or add additional context in comments.

2 Comments

You nailed it. Poor official documentation. Thank you!
The documentation you are using (tapanila.net) is not official. The official documentation is on azure.com - go to Documentation -> Web & Mobile -> Mobile Apps
1

Try to directly use mssql object in the code, because the objects in the list of the article which can be directly used for mobile service javascript backend. More details for mssql object, please see https://msdn.microsoft.com/en-us/library/azure/jj554212.aspx.

4 Comments

Thanks for your answer. I have tried this. But the Visual Studio online does not know anything about this object it seems. See image: dropbox.com/s/oxjekrhsdz7stjb/mssql.png?dl=0
Found a similar case here: stackoverflow.com/questions/28264430/… but no solutions. Maybe I am missing something in the Azure setup?
@LarsØrjanNese Does it works with ignoring code check? The code of the similar case seems to be from the offical tutorial azure.microsoft.com/en-us/documentation/articles/…. I doubt the issue was caused by inputting the incorrect user/password for SQL Azure. Please try to connect the SQL Azure alone before create mobile service instance.
I get access to the SQL Azure from "everywhere". And my app (iOS) is working like a charm to access the Azure SDK to run simple queries. But to use this api thing seems tricky.

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.