Azure SQL Managed Instance – Terraform command available

Published Sep 14 2021 07:04 AM 1,285 Views
Microsoft

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 mdcssqlmipm@microsoft.com

%3CLINGO-SUB%20id%3D%22lingo-sub-2749141%22%20slang%3D%22en-US%22%3EAzure%20SQL%20Managed%20Instance%20%E2%80%93%20Terraform%20command%20available%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2749141%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22SQLMIOPS%20cover.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F310299i2F6DBDDDD0107586%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22SQLMIOPS%20cover.png%22%20alt%3D%22SQLMIOPS%20cover.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EWe%20continue%20investment%20into%20%3CA%20title%3D%22Azure%20SQL%20Managed%20Instance%20%E2%80%93%20introduction%20to%20%23SQLMIOPS%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Ftag%2Fsqlmiops%2Ftg-p%2Fboard-id%2FAzureSQLBlog%22%20target%3D%22_self%22%3E%23sqlmiops%3C%2FA%3E%2C%20and%20after%20recent%20changes%20in%20%3CA%20title%3D%22Azure%20SQL%20MI%20now%20removes%20virtual%20cluster%20as%20part%20of%20the%20delete%20flow%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sql%2Fazure-sql-mi-now-removes-virtual-cluster-as-part-of-the-delete%2Fba-p%2F2703627%22%20target%3D%22_self%22%3Emanaged%20instance%20delete%20flow%2C%3C%2FA%3E%26nbsp%3B%3CSPAN%3EIaC%20(Infrastracture-as-Code)%26nbsp%3Barea%20is%20expanded%20with%26nbsp%3B%3C%2FSPAN%3ESQL%20Managed%20Instance%20terraform%20command.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECommand%20for%20Azure%20SQL%20Managed%20Instance%26nbsp%3B%20deployment%20is%20officially%20available%20in%20Terraform%20registry%20as%20part%20of%20the%20Azure%20provider%20under%20Database%20group%20of%20commands.%20So%20far%2C%20customers%20used%20ARM%20templates%20as%20workaround%20for%20deploying%20managed%20instance%2C%20but%20with%20recent%20changes%20(%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fhashicorp%2Fterraform-provider-azurerm%2Fblob%2Fv2.76.0%2FCHANGELOG.md%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EPR%202.76.0%20(September%2010%2C%202021)%3C%2FA%3E)%20all%20templates%20can%20be%20switched%20to%20the%20fresh%26nbsp%3B%3CA%20title%3D%22Terraform%20command%20for%20Azure%20SQL%20Managed%20Instance%22%20href%3D%22https%3A%2F%2Fregistry.terraform.io%2Fproviders%2Fhashicorp%2Fazurerm%2Flatest%2Fdocs%2Fresources%2Fsql_managed_instance%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Eazurerm_sql_managed_instance%3C%2FA%3E%20command.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20are%20couple%20of%20tips%20that%20can%20come%20handy%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EIf%20you%20have%20only%20one%20managed%20instance%20deployed%20in%20the%20subnet%20and%20you%20want%20to%20re-create%20it%2C%20first%20create%20new%20instance%2C%20and%20then%20remove%20the%20old%20one.%3CBR%20%2F%3E%3CEM%3EExplanation%3C%2FEM%3E%3A%20The%20only%20benefit%20of%20this%20order%20of%20operations%20is%20shorter%20duration.%20There%20is%20nothing%20that%20would%20prevent%20opposite%20order%20(first%20removing%20the%20old%20one%2C%20then%20creating%20new).%20Subsequent%20instance%20creations%20mostly%20require%20virtual%20cluster%20resize%20typically%20taking%20up%20to%202.5%20hours%20to%20complete.%20In%20case%20of%20first%20instance%20creation%20in%20the%20subnet%2C%20virtual%20cluster%20creation%20is%20triggered%20with%20typical%20duration%20of%204%20hours.%20Removal%20of%20the%20last%20instance%20in%20the%20subnet%20takes%20up%20to%201.5%20hours.%3CBR%20%2F%3E%3CEM%3EReference%3C%2FEM%3E%3A%26nbsp%3B%3CA%20title%3D%22Overview%20of%20Azure%20SQL%20Managed%20Instance%20management%20operations%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-sql%2Fmanaged-instance%2Fmanagement-operations-overview%23duration%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EManagement%20operations%20overview%20page%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3ERemoval%20of%20the%20last%20instance%20in%20subnet%20is%20long%20running%20operation%26nbsp%3B%20typically%20taking%201.5%20hours.%20Non-last%20instance%20removal%20is%20fast%20operation%20that%20completes%20in%20up%20to%205%20minutes.%3CBR%20%2F%3E%3CEM%3EExplanation%3C%2FEM%3E%3A%20Removal%20of%20the%20last%20instance%20in%20subnet%20will%20remove%20all%20dependent%20networking%20resources%20created%20as%20part%20of%20the%20instance%20creation%20including%20virtual%20cluster.%3CBR%20%2F%3E%3CEM%3EReference%3C%2FEM%3E%3A%26nbsp%3B%3CA%20title%3D%22Azure%20SQL%20MI%20now%20removes%20virtual%20cluster%20as%20part%20of%20the%20delete%20flow%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sql%2Fazure-sql-mi-now-removes-virtual-cluster-as-part-of-the-delete%2Fba-p%2F2703627%22%20target%3D%22_self%22%3EAzure%20SQL%20MI%20now%20removes%20virtual%20cluster%20as%20part%20of%20the%20delete%20flow%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EList%20of%20Azure%20SQL%20Managed%20Instance%20related%20commands%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20title%3D%22Terraform%20command%20for%20Azure%20SQL%20Managed%20Instance%22%20href%3D%22https%3A%2F%2Fregistry.terraform.io%2Fproviders%2Fhashicorp%2Fazurerm%2Flatest%2Fdocs%2Fresources%2Fsql_managed_instance%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Eazurerm_sql_managed_instance%20%7C%20Resources%20%7C%20hashicorp%2Fazurerm%20%7C%20Terraform%20Registry%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20title%3D%22Terraform%20command%20for%20Azure%20SQL%20Managed%20Instance%20-%20managed%20database%22%20href%3D%22https%3A%2F%2Fregistry.terraform.io%2Fproviders%2Fhashicorp%2Fazurerm%2Flatest%2Fdocs%2Fresources%2Fsql_managed_database%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Eazurerm_sql_managed_database%20%7C%20Resources%20%7C%20hashicorp%2Fazurerm%20%7C%20Terraform%20Registry%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EKey%20concepts%20to%20have%20in%20mind%20before%20deploying%20Azure%20SQL%20Managed%20Instance%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EIt%20is%20recommended%20to%20use%20larger%20IP%20address%20ranges%20for%20instance%20deployment%20(recommended%20subnet%20size%20is%20at%20least%20%2F26).%20Check%20how%20to%20%3CA%20title%3D%22Determine%20required%20subnet%20size%20and%20range%20for%20Azure%20SQL%20Managed%20Instance%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-sql%2Fmanaged-instance%2Fvnet-subnet-determine-size%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Edetermine%20required%20subnet%20size%20and%20range%20for%20Azure%20SQL%20Managed%20Instance%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EYou%20can%20deploy%20the%20instance%20in%20new%20subnet%20or%20use%20the%20existing%20one.%20Learn%20how%20to%20%3CA%20title%3D%22Configure%20an%20existing%20virtual%20network%20for%20Azure%20SQL%20Managed%20Instance%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-sql%2Fmanaged-instance%2Fvnet-existing-add-subnet%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Econfigure%20an%20existing%20virtual%20network%20for%20Azure%20SQL%20Managed%20Instance%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EInstance%20%3CA%20title%3D%22Overview%20of%20Azure%20SQL%20Managed%20Instance%20management%20operations%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-sql%2Fmanaged-instance%2Fmanagement-operations-overview%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Emanagement%20operations%3C%2FA%3E%20are%20long%20running%20as%20SQL%20Managed%20Instance%20relies%20on%20%3CA%20title%3D%22Connectivity%20architecture%20for%20Azure%20SQL%20Managed%20Instance%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-sql%2Fmanaged-instance%2Fconnectivity-architecture-overview%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Evirtual%20clusters%3C%2FA%3E.%20The%20virtual%20cluster%20represents%20a%20dedicated%20set%20of%20isolated%20virtual%20machines%20deployed%20inside%20the%20customer's%20virtual%20network%20subnet%2C%20ensuring%20the%20highest%20standard%20of%20security%20and%20the%20consistency%20even%20with%20such%20complex%20systems.%3C%2FLI%3E%0A%3CLI%3EAll%20resources%20created%20with%20first%20instance%20creation%20are%20removed%20from%20the%20subnet%20with%20last%20instance%20removal%2C%20%3CA%20title%3D%22Delete%20a%20subnet%20after%20deleting%20an%20Azure%20SQL%20Managed%20Instance%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-sql%2Fmanaged-instance%2Fvirtual-cluster-delete%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Eleaving%20the%20subnet%20empty%3C%2FA%3E.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EStay%20tuned%20with%20%23sqlmiops!%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EIndex%20article%3C%2FSTRONG%3E%3A%20%3CA%20title%3D%22Azure%20SQL%20Managed%20Instance%20%E2%80%93%20introduction%20to%20%23SQLMIOPS%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-sql%2Fazure-sql-managed-instance-introduction-to-sqlmiops%2Fba-p%2F2687265%22%20target%3D%22_self%22%3EAzure%20SQL%20Managed%20Instance%20%E2%80%93%20introduction%20to%20%23SQLMIOPS%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ECall%20to%20action%3C%2FSTRONG%3E%3A%20Nominate%20the%20topics%20for%20upcoming%20blog%20posts%20using%20comment%20section%20and%20votes%2C%20or%20writing%20directly%20to%20%3CA%20title%3D%22Azure%20SQL%20Managed%20Instance%20PM%20mail%20alias%22%20href%3D%22mailto%3Amdcssqlmipm%40microsoft.com%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Emdcssqlmipm%40microsoft.com%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2749141%22%20slang%3D%22en-US%22%3E%3CP%3ECommand%20for%20Azure%20SQL%20Managed%20Instance%20deployment%20is%20officially%20available%20in%20Terraform%20registry%20under%20Azure%20provider%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2749141%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20SQL%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20SQL%20Managed%20Instance%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Sep 14 2021 07:01 AM
Updated by: