Azure SQL Database – A Complete Guide
🌐 What is Azure SQL Database?
Azure SQL Database is Microsoft’s fully managed, cloud‑based relational database service. It runs on the latest stable SQL Server engine and takes care of patching, backups, upgrades, and high availability automatically. It’s part of the Azure SQL family, which also includes Azure SQL Managed Instance and SQL Server on Azure Virtual Machines.
⚡ Key Benefits
- Fully Managed – No need to maintain servers or install updates.
- High Availability – 99.99% uptime SLA.
- Scalable – Adjust compute and storage on demand.
- Secure – Built‑in encryption, threat detection, and compliance features.
- Latest Features First – New SQL Server capabilities arrive in Azure SQL before on‑premises releases.
🛠 Deployment Options
- Single Database – Ideal for isolated workloads with predictable performance.
- Elastic Pool – Share resources across multiple databases to save costs.
- Serverless – Auto‑pause and auto‑resume to save money on infrequent workloads.
📊 Purchasing Models
- vCore‑based – Choose CPU, memory, and storage; use Azure Hybrid Benefit for discounts.
- DTU‑based – Pre‑bundled compute, memory, and I/O for simpler pricing.
🔍 Common Use Cases
- Hosting web and mobile app backends.
- Storing business application data.
- Running analytics and reporting.
- Supporting multi‑tenant SaaS applications.
🚀 Getting Started
- Sign in to the Azure Portal.
- Search for Azure SQL Database and click Create.
- Choose your subscription, resource group, and database name.
- Select a compute tier (vCore or DTU) and configure storage.
- Set authentication (SQL or Azure AD) and networking options.
- Review and create — your database will be ready in minutes.
💡 Pro Tip: Start with the free tier to explore features without cost — you get 100,000 vCore‑seconds and 32 GB storage per month.
Azure SQL Database – Architecture Overview
🧑💻 Hands‑On Examples: Creating, Inserting & Querying Data
Once your Azure SQL Database is created, you can connect to it using:
- SQL Server Management Studio (SSMS) – for a full desktop experience.
- Azure Portal Query Editor – for quick, browser‑based queries.
1️⃣ Create a Table
Example SQL script to create a simple Customers table:
CREATE TABLE Customers (
CustomerID INT PRIMARY KEY IDENTITY(1,1),
FirstName NVARCHAR(50),
LastName NVARCHAR(50),
Email NVARCHAR(100),
CreatedDate DATETIME DEFAULT GETDATE()
);
2️⃣ Insert Data
Insert sample records into the Customers table:
INSERT INTO Customers (FirstName, LastName, Email)
VALUES
('John', 'Doe', 'john.doe@example.com'),
('Jane', 'Smith', 'jane.smith@example.com'),
('Ravi', 'Kumar', 'ravi.kumar@example.com');
3️⃣ Query Data
Retrieve all records from the Customers table:
SELECT CustomerID, FirstName, LastName, Email, CreatedDate FROM Customers;
💡 Running These in SSMS
- Open SSMS and connect to your Azure SQL Database using the server name, username, and password from the Azure Portal.
- Click New Query and paste the SQL script.
- Click Execute (or press F5) to run the commands.
💡 Running These in Azure Portal Query Editor
- Go to your Azure SQL Database resource in the Azure Portal.
- Click Query editor (preview) in the left menu.
- Sign in with your SQL or Azure AD credentials.
- Paste the SQL script and click Run.
🔹 Tip: Always test scripts in a development database before running them in production.
Comments
Post a Comment