Overview
Azure SQL Database is a fully managed relational database service built on Microsoft SQL Server. It handles most database management functions such as patching, backups, and monitoring, allowing developers to focus on building applications.
Getting Started
- Create a new Azure SQL Database in the Azure portal.
- Set up a server-level firewall rule to allow your client IP.
- Configure a database-level firewall for additional security.
- Connect using your preferred development language.
For a step‑by‑step guide see the quickstart tutorial.
Connection Strings
Below are sample connection strings for common languages. Replace {your_server}
, {your_database}
, {your_user}
, and {your_password}
with your values.
ADO.NET (C#)
Server=tcp:{your_server}.database.windows.net,1433;Initial Catalog={your_database};PersistSecurityInfo=False;User ID={your_user};Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
JDBC (Java)
jdbc:sqlserver://{your_server}.database.windows.net:1433;database={your_database};user={your_user}@{your_server};password={your_password};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
Node.js (tedious)
const config = {
server: '{your_server}.database.windows.net',
authentication: {
type: 'default',
options: {
userName: '{your_user}',
password: '{your_password}'
}
},
options: {
encrypt: true,
database: '{your_database}'
}
};
Sample Queries
These examples demonstrate common tasks.
Create a table
CREATE TABLE Employees (
EmployeeID INT IDENTITY(1,1) PRIMARY KEY,
FirstName NVARCHAR(50) NOT NULL,
LastName NVARCHAR(50) NOT NULL,
HireDate DATE NOT NULL,
Salary DECIMAL(10,2) NOT NULL
);
Insert data
INSERT INTO Employees (FirstName, LastName, HireDate, Salary)
VALUES ('Alice', 'Johnson', '2023-06-01', 85000.00),
('Bob', 'Smith', '2022-03-15', 72000.00);
Query with pagination
SELECT EmployeeID, FirstName, LastName, Salary
FROM Employees
ORDER BY HireDate DESC
OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY;
Best Practices
- Use Active Geo‑Replication for high availability.
- Enable Transparent Data Encryption (TDE) to protect data at rest.
- Implement Azure AD authentication instead of SQL authentication when possible.
- Monitor performance with Query Performance Insight and set up alerts.
- Scale resources using serverless compute tier for unpredictable workloads.