# Unauthorized 401 with Azure SQL

**URL:** <https://community.auth0.com/t/unauthorized-401-with-azure-sql/7913>\
**Category:** Get Help\
**Tags:** azure-sql, systemweb, aspnet\
**Created:** [August 21, 2017, 10:53am UTC](https://community.auth0.com/t/unauthorized-401-with-azure-sql/7913 "2017-08-21T10:53:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishalm](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@vishalm](https://community.auth0.com/u/vishalm)\
**Post date:** [August 21, 2017, 10:53am UTC](https://community.auth0.com/t/unauthorized-401-with-azure-sql/7913/1 "2017-08-21T10:53:01Z")

</div>

I am doing some testing in regards to importing users from my current database(Azure SQL). I have set all my connection settings as needed and also added the IP Addresses to my Azure SQL firewall, but still receiving Unauthorized 401 error when i try to check the connections using Auth0 provided UI.

Some help will be much appreciated.

Kind Regards,  
Vishal

---

<div class="post-metadata">

**Author:** ![vishalm](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@vishalm](https://community.auth0.com/u/vishalm)\
**Post date:** [August 22, 2017, 7:12am UTC](https://community.auth0.com/t/unauthorized-401-with-azure-sql/7913/2 "2017-08-22T07:12:49Z")

</div>

Below is my Database Action Script:  
function login(email, password, callback) {

```
  var Connection = require('tedious@1.11.0').Connection;
  var Request = require('tedious@1.11.0').Request;
  var TYPES = require('tedious@1.11.0').TYPES;

  var connection = new Connection({
    userName: 'username',
    password: 'password',
    server: 'server',
    options: {
      database: 'database',
      encrypt: true,
      rowCollectionOnRequestCompletion:true
    }
  });

  var query = "SELECT Id, Email, Password " +
    "FROM dbo.User WHERE Email = @Email";

  connection.on('debug', function (text) {
    // Uncomment next line in order to enable debugging messages
    console.log(text);
  }).on('errorMessage', function (text) {
    console.log(JSON.stringify(text, null, 2));
    return callback(text);
  }).on('infoMessage', function (text) {
    // Uncomment next line in order to enable information messages
    console.log(JSON.stringify(text, null, 2));
  });

  connection.on('connect', function (err) {
    if (err) { return callback(err); }

    var request = new Request(query, function (err, rowCount, rows) {
      if (err) {
        callback(new Error(err));
      } else if (rowCount < 1) {
        callback(new WrongUsernameOrPasswordError(email));
      } else {
        bcrypt.compare(password, rows[0][2].value, function (err, isValid) {
          if (err) { callback(new Error(err)); }
          else if (!isValid) { callback(new WrongUsernameOrPasswordError(email)); }
          else {
            callback(null, {
              user_id: rows[0][0].value,
              email: rows[0][1].value
            });
          }
        });
      }
    });

    request.addParameter('Email', TYPES.VarChar, email);
    connection.execSql(request);
  });
}

```

---

<div class="post-metadata">

**Author:** ![nicoflappo71](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@nicoflappo71](https://community.auth0.com/u/nicoflappo71)\
**Post date:** [October 6, 2017, 3:58am UTC](https://community.auth0.com/t/unauthorized-401-with-azure-sql/7913/3 "2017-10-06T03:58:48Z")

</div>

Hi, i’m having the same issue, have u been able to fix it?

---

<div class="post-metadata">

**Author:** ![amb101](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@amb101](https://community.auth0.com/u/amb101)\
**Post date:** [January 18, 2018, 10:40pm UTC](https://community.auth0.com/t/unauthorized-401-with-azure-sql/7913/4 "2018-01-18T22:40:03Z")

</div>

Hi, I am having the same problem. Has the issue been resolved?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/unauthorized-401-with-azure-sql/7913/5 "2018-03-02T05:56:02Z")

</div>


