Skip to content

Latest commit

 

History

History
82 lines (52 loc) · 3.7 KB

File metadata and controls

82 lines (52 loc) · 3.7 KB
title Quickstart: Create Instance with Terraform
description Learn how to create and deploy Azure SQL Managed Instance with Terraform
author vladai78
ms.author vladiv
ms.reviewer mathoma
ms.date 08/26/2025
ms.service azure-sql-managed-instance
ms.topic quickstart
ms.custom
devx-track-terraform

Quickstart: Create instance with Terraform - Azure SQL Managed Instance

Article tested with the following Terraform and Terraform provider versions:

This article shows how use Terraform to deploy an Azure SQL Managed Instance in a virtual network and a subnet associated with a route table and a network security group.

[!INCLUDE Terraform abstract]

In this article, you learn how to:

[!div class="checklist"]

  • Create all supporting services for SQL Managed Instance to run on
  • Deploy SQL Managed Instance

Prerequisites

[!INCLUDE open-source-devops-prereqs-azure-subscription.md]

  • In the general case, your user needs to have the role SQL Managed Instance Contributor assigned at subscription scope.
  • If provisioning in a subnet that is already delegated to Azure SQL Managed Instance, your user only needs the Microsoft.Sql/managedInstances/write permission assigned at subscription scope.
  • Install and configure Terraform

Implement the Terraform code

  1. Create a directory in which to test and run the sample Terraform code and make it the current directory.

  2. Create a file named providers.tf and insert the following code: [!code-terraformmaster]

  3. Create a file named main.tf and insert the following code: [!code-terraformmaster]

  4. Create a file named variables.tf and insert the following code: [!code-terraformmaster]

Initialize Terraform

[!INCLUDE terraform-init.md]

Create a Terraform execution plan

[!INCLUDE terraform-plan.md]

Apply a Terraform execution plan

[!INCLUDE terraform-apply-plan.md]

Verify the results

To verify the results within the Azure portal, browse to the new resource group. The new instance will be in the new resource group after it's deployed. To see the deployment progress keep your PowerShell open or navigate to the Azure portal, search for SQL Managed Instance and then filter all instances by status.

Clean up resources

[!INCLUDE terraform-plan-destroy.md]

Troubleshoot Terraform on Azure

Troubleshoot common problems when using Terraform on Azure

Next step

[!div class="nextstepaction"] Learn more about Azure SQL Managed Instance