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.
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:
- azurerm_sql_managed_instance | Resources | hashicorp/azurerm | Terraform Registry
- azurerm_sql_managed_database | Resources | hashicorp/azurerm | Terraform Registry
Key concepts to have in mind before deploying Azure SQL Managed Instance:
- It is recommended to use larger IP address ranges for instance deployment (recommended subnet size is at least /26). Check how to determine required subnet size and range for Azure SQL Managed Instance
- You can deploy the instance in new subnet or use the existing one. Learn how to configure an existing virtual network for Azure SQL Managed Instance
- 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.
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 mdcssqlmipm@microsoft.com