> For the complete documentation index, see [llms.txt](https://docs.smaq.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.smaq.io/documentation/connections/sql-databases/microsoft-azure-sql.md).

# Microsoft Azure SQL

### Step 1 — Collect connection details

In the Azure Portal:

1. **SQL databases → click your database**.
2. From **Overview**, copy the **Server name** (e.g. `acme-prod.database.windows.net`).
3. Note the **Database name**.
4. Default port is **1433**.

> **\[Screenshot needed]** Azure SQL Database Overview pane with Server name and Database name highlighted.

### Step 2 — Allow SMAQ's IPs in the firewall

1. **SQL Server → Networking** (the server resource, not the database).
2. Toggle **Public access** to Selected networks (if not already).
3. **Firewall rules → Add a rule** for each SMAQ outbound IP. Get the IPs from **<info@smaq.io>**.
4. Save.

> **\[Screenshot needed]** Firewall rules pane with SMAQ IPs listed.

### Step 3 — Create a read-only user

Connect to your DB as admin (via Azure Data Studio, SSMS, or `sqlcmd`):

```sql
CREATE LOGIN smaq_readonly WITH PASSWORD = 'long-random-string';
USE your_db;
CREATE USER smaq_readonly FOR LOGIN smaq_readonly;
EXEC sp_addrolemember 'db_datareader', 'smaq_readonly';
```

### Step 4 — Add the connection in SMAQ

1. SMAQ project → **Data Source → Add data source**.
2. Pick **Microsoft Azure SQL**.
3. Fill in:
   * **Host**: the server name (`acme-prod.database.windows.net`)
   * **Port**: 1433
   * **Database**, **Username** (`smaq_readonly`), **Password**
   * **SSL mode**: Require (Azure SQL always uses encrypted connections)
4. **Test connection** → **Connect**.

### Troubleshooting

* **"Cannot open server requested by the login"** — Azure firewall isn't allowing SMAQ. Double-check the IP rules and that you edited the rules on the server, not the database.
* **"Login failed for user"** — the user was created at the database level but the login wasn't created at the server level. Re-run `CREATE LOGIN ...`.
* **Slow queries** — Azure SQL has a service tier that limits DTU/vCore. Cheap tiers throttle aggressively under analytical workloads.

### Active Directory authentication

SMAQ doesn't currently support Azure AD-based authentication for Azure SQL. Use SQL authentication (username/password) instead. Talk to <info@smaq.io> if AAD auth is a hard requirement.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.smaq.io/documentation/connections/sql-databases/microsoft-azure-sql.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
