title: What permissions does Azure Mobile Services use to access an Azure SQL Database with the mssql object?
body: <p>I have set up an Azure Mobile Service (AMS) that's associated with an Azure SQL database, as usual. However, when I try to use a custom api to query another table (NOT a mobile services table) with the custom API <code>mssql</code> object, I get a permissions error:</p>
  
  <blockquote>
    <p>Error: [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'zwxABOesblahblahHYzLogin'.</p>
  </blockquote>
  
  <p>Some things to note:</p>
  
  <ul>
  <li>I had to drop delete the database and then re-create it with the same name after the mobile service was created. </li>
  <li>Mobile service name is 'abc', and the table I'm trying to access is owned by an 'abc' schema, not dbo. The other table was created from SQL Server Management studio via a standard T-SQL script.</li>
  </ul>
  
  <p>The AMS api script is very basic:</p>
  
  <pre><code>exports.get = function(request, response) {
      var mssql = request.service.mssql;
      var sql = "select * from abc.TestTable";
  
      mssql.query(sql, {
          success : function(results) {
              console.log("Results from SQL Query to TestTable:\n"+results);
              response.send(statusCodes.OK, results);    
          },
          error: function(err) {
              console.log("Error in SQL Query to TestTable:\n"+err);
              response.send(statusCodes.Error,err.message);
          }
  
      });
  
  };
  </code></pre>
  
  <p>So to my question(s)... what credentials are used by AMS to access the SQL database? How can I change permissions so that the script above just works (as implied by all the docs I've seen!). Or am I stuck with having to pass a connection string as suggested by this <a href="https://stackoverflow.com/questions/17835107/can-a-mobile-service-server-script-schedule-access-other-sql-azure-databases">question</a>.</p>
  
  <p>Thanks!</p>