Azure SQL Managed Instance – Terraform command available
Published Sep 14 2021 07:04 AM 8,070 Views

SQLMIOPS cover.png

We continue investment into #sqlmiops, and after recent changes in managed instance delete flow, IaC (Infrastracture-as-Code) area is expanded with SQL Managed Instance terraform command.


Command for Azure SQL Managed Instance  deployment is officially available in Terraform registry as part of the Azure provider under Database group of commands. So far, customers used ARM templates as workaround for deploying managed instance, but with recent changes (PR 2.76.0 (September 10, 2021)) all templates can be switched to the fresh azurerm_sql_managed_instance command.


There are couple of tips that can come handy:

  • If you have only one managed instance deployed in the subnet and you want to re-create it, first create new instance, and then remove the old one.
    Explanation: The only benefit of this order of operations is shorter duration. There is nothing that would prevent opposite order (first removing the old one, then creating new). Subsequent instance creations mostly require virtual cluster resize typically taking up to 2.5 hours to complete. In case of first instance creation in the subnet, virtual cluster creation is triggered with typical duration of 4 hours. Removal of the last instance in the subnet takes up to 1.5 hours.
    ReferenceManagement operations overview page
  • Removal of the last instance in subnet is long running operation  typically taking 1.5 hours. Non-last instance removal is fast operation that completes in up to 5 minutes.
    Explanation: Removal of the last instance in subnet will remove all dependent networking resources created as part of the instance creation including virtual cluster.
    ReferenceAzure SQL MI now removes virtual cluster as part of the delete flow


List of Azure SQL Managed Instance related commands:


Key concepts to have in mind before deploying Azure SQL Managed Instance:


Stay tuned with #sqlmiops!


Index article: Azure SQL Managed Instance – introduction to #SQLMIOPS

Call to action: Nominate the topics for upcoming blog posts using comment section and votes, or writing directly to

1 Comment
Version history
Last update:
‎Sep 02 2022 01:19 AM
Updated by: