> For the complete documentation index, see [llms.txt](https://docs.coupler.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coupler.io/destinations/categories/database/azure_sql/connection-setup.md). Agents can also search and read this documentation through its [MCP server](https://docs.coupler.io/~gitbook/mcp).

# Azure SQL Connection Setup

Set up the Azure SQL connection for Coupler.io: firewall, a Microsoft Entra ID service principal or a SQL login, and the database permissions it needs.

Coupler.io connects to Azure SQL with one of two authentication methods:

* **Option A — Microsoft Entra ID service principal** (default in Coupler.io). An app registration in your Microsoft Entra tenant signs in with a client secret. Works when SQL logins are disabled on the server.
* **Option B — SQL username/password.** A database user with a password. Requires SQL authentication to be enabled on the server.

Start with the steps for all methods, then follow the option you chose.

## Steps for all methods

{% stepper %}
{% step %}
**Find the server name and database name.** In the Azure portal, open **SQL databases** and select your database. On **Overview**, copy the **Server name** (for example `myserver.database.windows.net`) — this is the **Host** in Coupler.io — and note the database name.
{% endstep %}

{% step %}
**Allow Coupler.io in the server firewall.** Open the SQL server → **Security** → **Networking**. Under **Public network access**, choose **Selected networks**, then add two firewall rules:

| Rule name    | Start IP         | End IP           |
| ------------ | ---------------- | ---------------- |
| coupler-io-1 | `34.123.243.115` | `34.123.243.115` |
| coupler-io-2 | `34.170.96.92`   | `34.170.96.92`   |

Click **Save**. Keep **Connection policy** on **Default**.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
Serverless databases with **auto-pause** take up to a minute to resume, and the first run after a pause can time out. If Coupler.io writes on a schedule, consider turning auto-pause off for this database.
{% endhint %}

## Permissions Coupler.io needs

Whichever method you use, the Coupler.io user needs these permissions in the target database:

| What Coupler.io does                             | When                                  | Permission                                |
| ------------------------------------------------ | ------------------------------------- | ----------------------------------------- |
| Loads rows                                       | Every run                             | `INSERT` on the table or schema           |
| Creates the table, or drops and creates it again | Replace mode; Append into a new table | `CREATE TABLE`, and `ALTER` on the schema |
| Creates a new schema                             | Only if the schema doesn't exist      | `CREATE SCHEMA`                           |

In SQL Server, `ALTER` on a schema is what lets a user create and drop tables in it. The schema itself isn't changed, so this permission is needed even when the schema already exists.

The grants for Replace mode or Append into a new table. Replace `<schema>` with the schema Coupler.io writes to (`dbo` by default) and `<user>` with the user you create below:

```sql
GRANT CREATE TABLE TO [<user>];
GRANT ALTER, INSERT ON SCHEMA::<schema> TO [<user>];

-- Optional: let Coupler.io create new schemas
GRANT CREATE SCHEMA TO [<user>];
```

For **Append** into a table that already exists, `INSERT` on that table is enough:

```sql
GRANT INSERT ON OBJECT::<schema>.<table> TO [<user>];
```

{% hint style="warning" %}
A schema belongs to the user who created it. If another user created the schema or the table, grant `ALTER` on that schema to the Coupler.io user, or Replace mode fails with "Cannot drop the table".
{% endhint %}

## Option A — Microsoft Entra ID service principal

{% stepper %}
{% step %}
**Register an app for Coupler.io.** In the Azure portal, open **Microsoft Entra ID** → **App registrations** → **New registration**. Enter a name, for example `Coupler.io Azure SQL`, keep **Accounts in this organizational directory only**, and click **Register**. On the app's **Overview**, copy the **Application (client) ID** and the **Directory (tenant) ID**.
{% endstep %}

{% step %}
**Create a client secret.** In the app, open **Certificates & secrets** → **Client secrets** → **New client secret**. Choose an expiry and click **Add**. Copy the secret's **Value** right away — it's shown only once. Don't copy the **Secret ID**.
{% endstep %}

{% step %}
**Make sure the server has a Microsoft Entra admin.** Open the SQL server → **Settings** → **Microsoft Entra ID**. If no admin is set, click **Set admin** and choose a user or group, then **Save**. Only a Microsoft Entra user can add the app to the database in the next step.
{% endstep %}

{% step %}
**Add the app to the database and grant permissions.** Connect to the **target database** (not `master`) as the Microsoft Entra admin — for example with **Query editor** in the Azure portal, SQL Server Management Studio, or Visual Studio Code — and run, using the app's name from step 1. Replace `<schema>` with the schema Coupler.io writes to (`dbo` by default). These grants cover Replace mode and Append into a new table:

```sql
CREATE USER [Coupler.io Azure SQL] FROM EXTERNAL PROVIDER;
GRANT CREATE TABLE TO [Coupler.io Azure SQL];
GRANT ALTER, INSERT ON SCHEMA::<schema> TO [Coupler.io Azure SQL];
```

Add `GRANT CREATE SCHEMA TO [Coupler.io Azure SQL];` if Coupler.io should create new schemas. For Append into a table that already exists, you can grant less — see [Permissions Coupler.io needs](#permissions-coupler.io-needs).
{% endstep %}

{% step %}
**Connect in Coupler.io.** In the Azure SQL connection form, keep **Authentication method** on **Entra ID Service Principal secret** and fill in:

* **Host** — the server name, for example `myserver.database.windows.net`
* **Port** — `1433`
* **Database** — the target database name
* **Tenant ID** — the **Directory (tenant) ID**
* **Client ID** — the **Application (client) ID**
* **Client secret** — the secret's **Value**

Click **Save**. The details are checked on the first run.
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
Client secrets expire. Before the secret expires, create a new one in the app registration and update it in Coupler.io: open **Destinations**, select **Reconnect** in the connection's menu, and enter the new secret.
{% endhint %}

## Option B — SQL username/password

{% stepper %}
{% step %}
**Make sure SQL authentication is enabled.** Open the SQL server → **Settings** → **Microsoft Entra ID**. If **Support only Microsoft Entra authentication for this server** is turned on, SQL logins are rejected — use Option A, or turn this setting off.
{% endstep %}

{% step %}
**Create a database user for Coupler.io.** Connect to the **target database** (not `master`) as an admin and run. Replace `<schema>` with the schema Coupler.io writes to (`dbo` by default). These grants cover Replace mode and Append into a new table:

```sql
CREATE USER coupler_user WITH PASSWORD = '<strong password>';
GRANT CREATE TABLE TO coupler_user;
GRANT ALTER, INSERT ON SCHEMA::<schema> TO coupler_user;
```

Add `GRANT CREATE SCHEMA TO coupler_user;` if Coupler.io should create new schemas. For Append into a table that already exists, you can grant less — see [Permissions Coupler.io needs](#permissions-coupler.io-needs). This creates a user that exists only in this database, so you don't need a login in `master`.
{% endstep %}

{% step %}
**Connect in Coupler.io.** In the Azure SQL connection form, set **Authentication method** to **SQL username/password** and fill in:

* **Host** — the server name, for example `myserver.database.windows.net`
* **Port** — `1433`
* **Database** — the target database name
* **User** — `coupler_user`
* **Password** — the password from the previous step

Click **Save**. The details are checked on the first run.
{% endstep %}
{% endstepper %}

## Check the connection

Run the data flow once. If it fails, the error in **Flow settings** → **History** tells you what to fix — see [Azure SQL common issues](https://docs.coupler.io/destinations/categories/database/azure_sql.md#azure-sql-common-issues).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.coupler.io/destinations/categories/database/azure_sql/connection-setup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
