Skip to main content
Version: v2.x

Using Hasura with an MS SQL on Azure Database

Available on: Cloud


This guide explains how to connect a new or existing MS SQL database on Azure to a Hasura Cloud project. If you're exploring MS SQL on Azure, and are interested in migrating an existing MS SQL database, check out their docs before continuing below.

Step 1: Sign up or log in to Hasura Cloud

Navigate to Hasura Cloud and sign up or log in.

Step 2: Create a Hasura Cloud project

On the Hasura Cloud dashboard, create a new project:

Create Hasura Cloud project

After the project is initialized successfully, click on Launch Console to open the Hasura Console in your browser.

On the Hasura Console, navigate to Data -> Manage -> Connect Database -> Connect existing database:

You will get prompted for a MS SQL Database URL. We will create this in the next step and then come back here.

Hasura Cloud database setup

Step 3: Create an MS SQL Instance on Azure (skip if you have an existing DB)

Log into the Azure Console.

On the top, click on Search and type "SQL Server" into the search field. Then click on SQL Servers:

Navigate to SQL Servers on Azure

Click on the Create button:

Create database in Azure

Select the current Subscription (Billing Account) and the resource group. Fill in all the necessary fields. In the Authentication part, select Use SQL Authentication and fill the username and password for the SQL user.

Fill all required fields to create database

Change additional settings or add tags to the instance if required. Once you reach to Review + Create tab, review all the fields. You can go back and change any field if required. Then, click on Create to start deploying the server instance.

Review and create SQL Server instance

Step 4: Allow connections to your DB from Hasura Cloud

Once Azure provisions the server, navigate to the server instance page and click on Show networking settings.

Go to networking settings

Back on Hasura Cloud, copy the IP address in the Hasura Cloud IP field on the project's details view.

Hasura Cloud IP field

On Azure, under Firewell rules in networking settings, click on Add a firewall rule. Name the firewall rule and paste the Hasura cloud IP on both the Start IP and End IP input boxes:

Add IP to firewall

After entering the IP of your Hasura Cloud project, click on OK and then click on Save at end of the page for the changes to take effect.

Step 5: Create database

Go to the SQL Server instance's home and click on Create Database

Create Database on SQL Server

Fill in all the required fields and additional settings if required. Click on Review + create and create the database.

Review and create database

Step 6: Construct the database connection URL

The structure of the database connection URL looks as follows:

Driver={ODBC Driver 17 for SQL Server};Server=myServerAddress;Database=myDataBase;UID=myUsername;PWD=myPassword;

We recommend copying and pasting this string into the Hasura Console's Database URL field (in the next step) to serve as a template. Using the information below, you can modify the attributes to meet your databases's values.

Copy the server name from instance home.

Copy server name
  • Driver: Driver to use for connection to the SQL Server. If you are not sure, use ODBC Driver 17 for SQL Server.
  • Server: The server name copied from the instance page.
  • Database: Database name created in step 5.
  • UID: Username for the SQL User created in step 3.
  • PWD: Password for the SQL User created in step 3.

Step 6: Finish connecting the database

Back on Hasura Console, enter and modify the connection string that we referenced in step 6:

Database setup

Then click Connect Database.


For security reasons, it is recommended to set database URLs as env vars and using the env vars to connect to the databases in place of the raw database URLs.

Voilà. You are ready to start developing.

Hasura console

Next steps

You can check out our 30-Minute Hasura Basics Course and other GraphQL & Hasura Courses for a more detailed introduction to Hasura.

You can also click the gear icon to manage your Hasura Cloud project. (e.g. add collaborators, env vars or custom domains).

Project actions

For more information on which SQL Server features we support, check out this page!