Microsoft Azure

Tutorials: Get started with Azure SQL Database

Welcome to the Azure SQL Database Guide

This tutorial will guide you through the essential steps of getting started with Azure SQL Database, a fully managed Platform as a Service (PaaS) database engine that handles most of the database management functions such as upgrading, patching and backups without user involvement.

Azure SQL Database offers:

Step 1: Creating an Azure SQL Database

Prerequisites: An active Azure subscription.

1. Sign in to the Azure portal.

2. Search for "Azure SQL" and select SQL databases.

3. Click Create.

4. Fill in the required details: Subscription, Resource group, Database name, Server name, Compute + Storage settings, and Administrator login credentials.

5. Review and click Create.

Step 2: Connecting to Your Database

Once your database is created, you can connect to it using various tools.

Using Azure Data Studio (Recommended):

  1. Download and install Azure Data Studio.
  2. Open Azure Data Studio and click New Connection.
  3. Enter the Server name (your Azure SQL server name, e.g., your-server-name.database.windows.net).
  4. Select SQL Login and enter your Administrator login and password.
  5. Click Connect.

Using SQL Server Management Studio (SSMS):

  1. Download and install SQL Server Management Studio.
  2. Follow similar steps as for Azure Data Studio, using your server name and credentials.

Step 3: Designing and Creating Tables

After connecting, you can create tables to store your data.

For example, to create a simple Products table:

CREATE TABLE Products (
    ProductID INT PRIMARY KEY IDENTITY(1,1),
    ProductName VARCHAR(255) NOT NULL,
    Category VARCHAR(100),
    Price DECIMAL(10, 2)
);

You can execute this T-SQL script using your connected tool.

Step 4: Writing Basic Queries

Interact with your data using SQL queries.

Insert Data:

INSERT INTO Products (ProductName, Category, Price)
VALUES ('Laptop', 'Electronics', 1200.00);

Select Data:

SELECT ProductID, ProductName, Price
FROM Products
WHERE Category = 'Electronics';

Step 5: Performance Tuning Basics

Ensure your database performs optimally.

  • Indexes: Create appropriate indexes to speed up data retrieval.
  • Query Optimization: Analyze query execution plans to identify bottlenecks.
  • Resource Scaling: Adjust the performance tier (DTUs or vCores) if needed.
  • Azure SQL Analytics: Use built-in tools for performance monitoring and recommendations.

Step 6: Security Best Practices

Protect your data with robust security measures.

  • Firewall Rules: Configure server and database firewalls to restrict access.
  • Authentication: Use Azure Active Directory authentication for enhanced security.
  • Encryption: Enable Transparent Data Encryption (TDE) for data at rest.
  • Auditing: Set up auditing to track database events.

This guide provides a starting point. Explore the official Azure SQL Database documentation for more in-depth information and advanced features.