Getting Started with Azure SQL Database

Welcome to Azure SQL Database! This guide will walk you through the essential steps to get started with Microsoft's fully managed relational database service in the cloud.

Key Benefits

Prerequisites

Before you begin, ensure you have:

Getting Started Steps

  1. Create an Azure SQL Database Server

    A logical server is a management construct for a collection of databases. It contains logins and properties that are inherited by the child databases.

    Using Azure Portal:

    1. Navigate to the Azure portal and search for "SQL servers".
    2. Click "Create".
    3. Fill in the required details: Subscription, Resource group, Server name, Administrator login, and Password.
    4. Click "Review + create" and then "Create".

    Using Azure CLI:

    az sql server create \
        --name your-server-name \
        --resource-group your-resource-group \
        --location your-region \
        --admin-user your-admin-login \
        --admin-password your-admin-password
  2. Create a SQL Database

    Once you have a server, you can create a database on it. You can choose from various service tiers based on your performance and cost requirements.

    Using Azure Portal:

    1. In your SQL server resource, click "Create database".
    2. Select the resource group and server.
    3. Enter a database name.
    4. Choose a compute + storage option (e.g., Basic, Standard, Premium, or Business Critical). For testing, the "Basic" tier is often sufficient.
    5. Click "Review + create" and then "Create".

    Using Azure CLI:

    az sql db create \
        --resource-group your-resource-group \
        --server your-server-name \
        --name your-database-name \
        --edition Basic \
        --service-objective Basic
  3. Configure Firewall Rules

    By default, Azure SQL Database is protected by a firewall. You need to configure rules to allow access from your IP address or specific Azure services.

    Using Azure Portal:

    1. Navigate to your SQL server resource.
    2. Under "Security", click "Networking".
    3. To allow your current client IP address, click "Add current client IP address".
    4. You can also add custom IP address ranges.
    5. Click "Save".

    Using Azure CLI:

    az sql server firewall-rule create \
        --resource-group your-resource-group \
        --server your-server-name \
        --name AllowYourIP \
        --start-ip-address your.public.ip.address \
        --end-ip-address your.public.ip.address
    Security Note: Avoid using 0.0.0.0 for start and end IP addresses in production environments, as it opens your server to the internet. Configure more restrictive rules as needed.
  4. Connect to Your Database

    You can connect to your Azure SQL Database using various tools:

    • SQL Server Management Studio (SSMS): A popular Windows-based tool for database administration.
    • Azure Data Studio: A cross-platform database tool.
    • Application Code: Use ADO.NET, JDBC, ODBC, PHP, Node.js, Python, or other language-specific drivers.

    When connecting, you'll typically use:

    • Server name: your-server-name.database.windows.net
    • Database name: your-database-name
    • Login: Your administrator login
    • Password: Your administrator password

    For application connections, consider using Azure Active Directory authentication for enhanced security.

Next Steps

Now that you have your Azure SQL Database set up, you can: