The Senator
The Senator

Reputation: 5401

How do I create a database in an elastic pool using bicep?

I'm trying to set up a database into an elastic pool using Bicep. So far I've created a sql server and a related elastic pool successfully. When I try to then create a database that refers to these parts I get unstuck with a helpful error from Azure

'The language expression property array index '1' is out of bounds.'

I'm really unclear on what settings I need to put in the SKU and other properties of the sqlServer configuration. So far I have the following:

resource sqlDatabase 'Microsoft.Sql/servers/databases@2022-05-01-preview' = {
  parent: sqlServer
  name: databaseName
  location: location
  sku: {
    name: databaseSku
  }
  properties: {
    elasticPoolId: elasticPoolId
    collation: collation
    maxSizeBytes: maxDatabaseSizeInBytes
    catalogCollation: collation
    zoneRedundant: zoneRedundant
    readScale: 'Disabled'
    requestedBackupStorageRedundancy: 'Zone'
  }
}

I want to use the StandardElastic pool and I've tried passing that as the databaseSku and I want to use 50 DTU's as the limit. But there is capacity, family, size and tier and from powershell I get these sorts of options:

Sku           Edition           Family    Capacity    Unit    Available
------------  ----------------  --------  ----------  ------  -----------
StandardPool  Standard                    50          DTU     True
StandardPool  Standard                    100         DTU     True
StandardPool  Standard                    200         DTU     True
StandardPool  Standard                    300         DTU     True

So how do I map my sql database onto my sql server on that pool using the 50 DTU StandardPool settings? Capacity appears to be a string as well on this template!

Upvotes: 1

Views: 1826

Answers (1)

The Senator
The Senator

Reputation: 5401

I found out that firstly you don't supply an sku to the sql database as it inherits the SKU information from the pool (which makes sense). Secondly that in my reference to the elastic pool above I was using the following syntax

resource elasticPool 'Microsoft.Sql/servers/elasticPools@2022-05-01-preview' 
existing = { 
  name: 'mything-pool'
}

And had excluded the PARENT for the pool, so the correct reference to the pool would have been

resource elasticPool 'Microsoft.Sql/servers/elasticPools@2022-05-01- 
preview' existing = {
  name: 'mything-pool'
  parent: **dbServer**
}

Which then fixed my obscure error

Upvotes: 1

Related Questions