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. Reference: Management 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. Reference: Azure SQL MI now removes virtual cluster as part of the delete flow
List of Azure SQL Managed Instance related commands:
Instance management operations are long running as SQL Managed Instance relies on virtual clusters. The virtual cluster represents a dedicated set of isolated virtual machines deployed inside the customer's virtual network subnet, ensuring the highest standard of security and the consistency even with such complex systems.
All resources created with first instance creation are removed from the subnet with last instance removal, leaving the subnet empty.