Azure Database SQL Server Elasticpool

This page shows how to write Terraform and Azure Resource Manager for Database SQL Server Elasticpool and write them securely.

azurerm_mssql_elasticpool (Terraform)

The SQL Server Elasticpool in Database can be configured in Terraform with the resource name azurerm_mssql_elasticpool. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

elasticpool.tf#L15
resource "azurerm_mssql_elasticpool" "dtu_elasticpool" {
  name                = "LOC-ENV-POOL"
  resource_group_name = azurerm_resource_group.paas_rsg.name
  location            = azurerm_resource_group.paas_rsg.location
  server_name         = azurerm_sql_server.sql_server.name
  max_size_gb         = "1024"
sqlha.tf#L30
resource "azurerm_mssql_elasticpool" "example" {
  name                = "test-epool"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  server_name         = azurerm_sql_server.example.name
  license_type        = "LicenseIncluded"
az_sql_server.tf#L25
resource "azurerm_mssql_elasticpool" "tst_epool" {
  name                = var.epool_name
  resource_group_name = local.rg_name
  location            = local.location
  server_name         = azurerm_mssql_server.tst_sqlsvr.name
  max_size_gb         = 50
main.tf#L1
resource "azurerm_mssql_elasticpool" "elasticpool" {
  name                = var.name
  resource_group_name = var.resource_group_name
  location            = var.location
  server_name         = var.server_name
  max_size_gb         = var.max_size_gb
SQLServer.tf#L23
resource "azurerm_mssql_elasticpool" "epool-primary" {
    name                = replace(local.basename, "##", "epool")
    resource_group_name = var.ResourceGroup
    location            = var.Location
    server_name         = azurerm_mssql_server.azsqlserver-primary.name
    license_type        = var.Licensing
main.tf#L1
resource "azurerm_mssql_elasticpool" "elasticpool" {
  name                = var.name
  resource_group_name = var.resource_group_name
  location            = var.location
  server_name         = var.server_name
  max_size_gb         = var.max_size_gb
elastic_pool.tf#L12
resource "azurerm_mssql_elasticpool" "elasticpool" {

  name                = azurecaf_name.elasticpool.result
  resource_group_name = var.resource_group_name
  location            = var.location
  server_name         = var.server_name
elastic_pool.tf#L12
resource "azurerm_mssql_elasticpool" "elasticpool" {

  name                = azurecaf_name.elasticpool.result
  resource_group_name = var.resource_group_name
  location            = var.location
  server_name         = var.server_name
elastic_pool.tf#L12
resource "azurerm_mssql_elasticpool" "elasticpool" {

  name                = azurecaf_name.elasticpool.result
  resource_group_name = var.resource_group_name
  location            = var.location
  server_name         = var.server_name
main.tf#L3
resource "azurerm_mssql_elasticpool" "elastic" {

    name = var.elastic_pool_name
    resource_group_name = var.resource_group
    location = var.location
    server_name = var.server_name

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Allows you to manage an Azure SQL Elastic Pool via the v3.0 API which allows for vCore and DTU based configurations.

Tips: Best Practices for The Other Azure Database Resources

In addition to the azurerm_mariadb_firewall_rule, Azure Database has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

azurerm_mariadb_firewall_rule

Ensure database firewalls do not permit public access

It is better to restrict IP address ranges that can access the database by firewall rules. If both start_ip_address and end_ip_address are set to 0.0.0.0, it blocks connections from the Internet and accepts connections from all Azure datacenter IP addresses.

risk-label

azurerm_mariadb_server

Ensure that access to Azure SQL Database is restricted

It is better to disable public access to the database to avoid unwilling communications with unknown services if not required.

risk-label

azurerm_mssql_database_extended_auditing_policy

Ensure to configure retention periods of database auditing to enough duration

It is better to configure retention periods of database auditing to enough duration. It would be better to set greater than at least 90 days.

risk-label

azurerm_mssql_server

Ensure to enable auditing on Azure SQL databases

It is better to enable auditing on Azure SQL databases. It helps you maintain regulatory compliance, monitor the activities indicating unexpected incidents or suspected security violations.

risk-label

azurerm_mssql_server_security_alert_policy

Ensure to configure at least one email address for threat alerts

It is better to configure at least one email address for threat alerts. SQL Server is able to send alerts for threat detection via emails and it could support us to notice the incident on time.

risk-label

azurerm_mysql_firewall_rule

Ensure database firewalls do not permit public access

It is better to restrict IP address ranges that can access the database by firewall rules. If both start_ip_address and end_ip_address are set to 0.0.0.0, it blocks connections from the Internet and accepts connections from all Azure datacenter IP addresses.

risk-label

azurerm_mysql_server

Ensure to disable public access to database

It is better to disable public access to the database to avoid unwilling communications with unknown services if not required.

risk-label

azurerm_postgresql_firewall_rule

Ensure database firewalls do not permit public access

It is better to restrict IP address ranges that can access the database by firewall rules. If both start_ip_address and end_ip_address are set to 0.0.0.0, it blocks connections from the Internet and accepts connections from all Azure datacenter IP addresses.

risk-label

azurerm_postgresql_server

Ensure to disable public access to database

It is better to disable public access to the database to avoid unwilling communications with unknown services if not required.

risk-label

azurerm_sql_firewall_rule

Ensure database firewalls do not permit public access

It is better to restrict IP address ranges that can access the database by firewall rules. If both start_ip_address and end_ip_address are set to 0.0.0.0, it blocks connections from the Internet and accepts connections from all Azure datacenter IP addresses.

risk-label

azurerm_sql_server

Ensure to enable auditing on Azure SQL databases

It is better to enable auditing on Azure SQL databases. It helps you maintain regulatory compliance, monitor the activities indicating unexpected incidents or suspected security violations.

Review your Azure Database settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

Microsoft.Sql/servers/elasticPools (Azure Resource Manager)

The servers/elasticPools in Microsoft.Sql can be configured in Azure Resource Manager with the resource name Microsoft.Sql/servers/elasticPools. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

ElasticPoolList.json#L15
            "type": "Microsoft.Sql/servers/elasticPools",
            "location": "Japan East",
            "kind": null,
            "properties": {
              "creationDate": "2017-02-10T01:27:21.32Z",
              "edition": "Basic",
elastic-pool.json
{
    "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "resource_prefix": {
ElasticPoolList.json#L15
            "type": "Microsoft.Sql/servers/elasticPools",
            "location": "Japan East",
            "kind": null,
            "properties": {
              "creationDate": "2017-02-10T01:27:21.32Z",
              "edition": "Basic",
ElasticPoolListByServer.json#L15
            "type": "Microsoft.Sql/servers/elasticPools",
            "location": "Japan East",
            "kind": null,
            "sku": {
              "name": "GP_Gen4_2",
              "tier": "GeneralPurpose",
azure.com_sql-elasticPools_2014-04-01.json#L160
                      "type": "Microsoft.Sql/servers/elasticPools"
                    },
                    {
                      "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-2369/providers/Microsoft.Sql/servers/sqlcrudtest-8069/elasticPools/sqlcrudtest-3191",
                      "kind": null,
                      "location": "Japan East",
ElasticPoolList.json#L15
            "type": "Microsoft.Sql/servers/elasticPools",
            "location": "Japan East",
            "kind": null,
            "properties": {
              "creationDate": "2017-02-10T01:27:21.32Z",
              "edition": "Basic",
ElasticPoolList.json#L15
            "type": "Microsoft.Sql/servers/elasticPools",
            "location": "Japan East",
            "kind": null,
            "properties": {
              "creationDate": "2017-02-10T01:27:21.32Z",
              "edition": "Basic",
ElasticPoolListByServer.json#L15
            "type": "Microsoft.Sql/servers/elasticPools",
            "location": "Japan East",
            "kind": null,
            "sku": {
              "name": "GP_Gen4_2",
              "tier": "GeneralPurpose",
ElasticPoolList.json#L15
            "type": "Microsoft.Sql/servers/elasticPools",
            "location": "Japan East",
            "kind": null,
            "properties": {
              "creationDate": "2017-02-10T01:27:21.32Z",
              "edition": "Basic",
ElasticPoolListByServer.json#L15
            "type": "Microsoft.Sql/servers/elasticPools",
            "location": "Japan East",
            "kind": null,
            "sku": {
              "name": "GP_Gen4_2",
              "tier": "GeneralPurpose",

Parameters

  • apiVersion required - string
  • location required - string

    Resource location.

  • name required - string

    The name of the elastic pool to be operated on (updated or created).

  • properties required
      • databaseDtuMax optional - integer

        The maximum DTU any one database can consume.

      • databaseDtuMin optional - integer

        The minimum DTU all databases are guaranteed.

      • dtu optional - integer

        The total shared DTU for the database elastic pool.

      • edition optional - string

        The edition of the elastic pool.

      • storageMB optional - integer

        Gets storage limit for the database elastic pool in MB.

      • zoneRedundant optional - boolean

        Whether or not this database elastic pool is zone redundant, which means the replicas of this database will be spread across multiple availability zones.

  • tags optional - string

    Resource tags.

  • type required - string

Frequently asked questions

What is Azure Database SQL Server Elasticpool?

Azure Database SQL Server Elasticpool is a resource for Database of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Database SQL Server Elasticpool?

For Terraform, the Dann1112/terratemps, fzameen/Appvia_Lab and anupam-sy/Terraform_Azure-Lab source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the rajithanitc/arm-resourcehealthswagger, QuanTomiZaH/Configuration-Tools and assing/alerts-extension source code examples are useful. See the Azure Resource Manager Example section for further details.