Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Azure SQL database instance with Min 0,5 vCores with Terraform?

I have Terraform and setting up Azure SQL database.

Currently Compute Hardware are defined as in Terraform:

requested_service_objective_name = "GP_S_Gen5_4"

This will configure Compute Hardware for Max vCores 4 and Min vCores 1.

I have need to configure min vCores as 0,5. If I set up 0.5 and then deploy Terraform with "GP_S_Gen5_4", I get automatically upgraded to Min vCores 1.

Is there anything I can do to configure size as 0,5 or is 1 actual min when deployed by Terraform?

enter image description here

like image 665
Kenny_I Avatar asked Nov 04 '25 07:11

Kenny_I


1 Answers

The resource azurerm_mssql_database does not have an attribute to set max vcores, it is specified in the last part of the sku_name. So if you want to have more max vcores, increase the sku. Set min_capacity to the minimum amount of vcores that you would need. Set auto_pause_delay_in_minutes to force the database to go into pause mode after x minutes of inactivity. This variable should be 60 minutes or higher, you can also set it to -1, which would leave the database running on the minimum capacity.

I would not recommend using azurerm_mssql_elasticpool if you need a normal sql database, it has other purposes. See below or read the documentation:

enter image description here

Some general recommendations/guidelines:

  • If you need a fast scaling database, don't set the minimum amount of vcores too low. Vcore scaling also takes some time to propagate.
  • Set databases in development and testing environments to auto-pause delay to save costs when not used. Preferably to the minimum of 60 minutes.
  • For frequently used production environments, set auto pause delay to -1.
  • The database will generally take some time to start after the first request. Your application has to be able to handle connection retries when the database is paused. I have seen applications that did not do this properly, resulting in wierd behaviour.
like image 149
Nebulastic Avatar answered Nov 06 '25 04:11

Nebulastic