Deploy Azure SQL Database with Terraform
Define and deploy an Azure SQL Server and database using Terraform with firewall rules, variables, and output values in this hands-on lab.

Lab overview
Azure SQL Database is Microsoft's fully managed relational database service, offering built-in high availability, automated backups, and elastic scaling without the overhead of managing virtual machines or operating system patches. When combined with Terraform, database infrastructure becomes version-controlled, repeatable, and auditable: critical properties for teams managing databases across development, staging, and production environments.
In this lab, you will write Terraform configuration files to provision an Azure SQL Server and database, configure server-level firewall rules for network access control, manage administrator credentials securely using Terraform sensitive variables, and output connection information for downstream application use. You will execute the full Terraform workflow from initialization through apply and verify the deployed resources in the Azure Portal.
Objectives
By completing this intermediate lab, you will be able to:
- Define an Azure SQL Server and database using Terraform azurerm_mssql_server and azurerm_mssql_database resources
- Use Terraform variables to manage administrator credentials securely with sensitive input values
- Configure server-level firewall rules using azurerm_mssql_firewall_rule to control network access
- Output the SQL Server fully qualified domain name (FQDN) and connection string from Terraform
- Execute the full Terraform workflow (init, plan, apply) to deploy database infrastructure
- Verify the deployed SQL Server, database, and firewall rules in the Azure Portal
Who is this lab for?
This lab is designed for:
- Cloud Engineers who need to provision and manage Azure SQL Databases using Infrastructure as Code
- DevOps Practitioners looking to automate database deployments as part of their Terraform-managed infrastructure
- Developers who want to understand how to define Azure database resources declaratively with Terraform
Verified against your live environment
An automated validation engine inspects your actual resources and configurations as you work. Completion means the task was performed — not multiple choice, real-world proficiency.
More labs like this
Deploy a Full Azure Environment Using Bicep Infrastructure as Code
Write modular Bicep templates to deploy a VNet, App Service, SQL Database, and Key Vault, then deploy the full environment using Azure CLI.
Deploy Azure Container Apps with Terraform
Use Terraform to define and deploy an Azure Container App with ingress, secrets, environment variables, and scaling rules.
Introduction to Infrastructure as Code with Terraform on AWS
Write your first HCL configuration and deploy a DynamoDB table to AWS using Terraform's init, plan, and apply workflow.
Related reading
Environment
Every lab includes
- Real environment, pre-credentialed
- Automated checks on every step
- Isolated sandbox, auto cleanup
- AI-recommended next steps
Lab curriculum
- 01
Logging into Azure CLI
- 02
Defining SQL Server and Database with Terraform
1 automated check
- 03
Configuring Firewall Rules and Terraform Outputs
1 automated check
- 04
Deploying SQL Database Infrastructure with Terraform
1 automated check
- 05
Verifying SQL Resources in the Azure Portal
1 automated check
Skills validated
Not the lab you were looking for?
Browse 150+ hands-on labs across AWS, Azure, Kubernetes, Docker, and cloud security.