Deploy and Manage Azure SQL Database
This tutorial guides you through the process of deploying and managing an Azure SQL Database instance. You'll learn how to create a database, configure its settings, and perform basic management tasks.
Note: This tutorial assumes you have an Azure account with an active subscription. If you don't have one, you can create a free account before you begin.
Step 1: Create an Azure SQL Database Server
Before you can create a database, you need an Azure SQL Database server. This server acts as a logical container for your databases.
- Sign in to the Azure portal.
- In the search bar at the top, type "Azure SQL" and select "Azure SQL" from the results.
- Click on "SQL servers" and then "+ Create".
- Fill in the required details:
- Subscription: Select your active subscription.
- Resource group: Create a new one or select an existing one.
- Server name: Enter a globally unique name for your server.
- Location: Choose a region close to your users.
- Administrator login: Create a username for the server admin.
- Password: Create a strong password.
- Click "Review + create" and then "Create".
Step 2: Create a SQL Database
Once your server is provisioned, you can create a new SQL database.
- Navigate to the SQL server you just created.
- Under "Data management", select "Databases" and then "+ New database".
- Configure the database settings:
- Database name: Provide a name for your database.
- Compute + storage: Select a service tier and size appropriate for your needs. For this tutorial, the Basic tier is sufficient.
- Collation: Usually, the default is fine.
- Click "Review + create" and then "Create".
Step 3: Connect to Your SQL Database
After the database is deployed, you can connect to it using various tools.
We'll use Azure Data Studio for this example.
- Download and install Azure Data Studio.
- Open Azure Data Studio and create a new connection.
- Enter the following connection details:
- Connection type: Microsoft SQL Server
- Server: Your server name (e.g.,
your-server-name.database.windows.net
) - Authentication type: SQL Login
- User name: Your administrator login
- Password: Your administrator password
- Click "Connect".
You should now see your database listed in the Connections pane.
Step 4: Basic Management Tasks
Firewall Rules
To allow connections from your IP address, you need to configure firewall rules.
- In the Azure portal, go to your Azure SQL server.
- Under "Security", select "Firewalls and virtual networks".
- Click "Add a client IP" to add your current IP address, or manually enter IP address ranges.
- Click "Save".
Monitoring Performance
Azure provides tools to monitor your database performance.
- Navigate to your Azure SQL Database in the Azure portal.
- Under "Monitoring", you can find metrics like CPU usage, data IO, and storage.
- The "Query Performance Insight" feature can help identify problematic queries.
Backups and Restore
Azure SQL Database automatically performs backups.
- Your database is automatically backed up regularly.
- You can restore your database to a previous point in time from the database's overview page in the Azure portal.
- For more advanced backup and restore options, explore "Active Geo-Replication" and "Auto-failover groups".
Next Steps
Congratulations! You have successfully deployed and learned basic management tasks for an Azure SQL Database. Continue learning by exploring: