Kenny_I
Kenny_I

Reputation: 2503

How to create Microsoft.DBforPostgreSQL with Bicep?

I would like to create PostgreSQL for location based service needs. I would install GIS extensions next.

I have created manually Azure Database for PostgreSQL flexible server to decide correct config. "sku": {"name": "Standard_B1ms","tier": "Burstable"} I wanted to create Single server, but it was not available in Europe for some reason. I thought that missing Burstable is good for initial POC, but general purpose is good as well.

Now trying to create PostgreSQL with Bicep. However I have difficulty to set valid server. Firstly Burstable was not available. Next I cannot set valid sku name.

az deployment group create:

{"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource 
deployment operation failed. Please list deployment operations for details. Please see 
https://aka.ms/DeployOperations for usage details.","details": 
[{"code":"BadRequest","message":"{\r\n  \"error\": {\r\n    \"code\": 
\"InvalidEditionSloCombination\",\r\n    \"message\": \"The edition 
GeneralPurpose does not support the service objective Standard_D2s_v3\"\r\n  }\r\n}"}]}}

main.bicep:

resource symbolicname 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
  name: 'my-postgresql-dev'
  location: 'West Europe'
  tags: {
    tagName1: 'tagValue1'
    tagName2: 'tagValue2'
  }
  sku: {
    name: 'Standard_D2s_v3' 
    tier: 'GeneralPurpose'
  }
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    administratorLogin: 'sqladmin'
    administratorLoginPassword: 'asfar43efw!sdf'
    storageProfile: {
      backupRetentionDays: 7
      geoRedundantBackup: 'Disabled'
      storageMB: 32000
    }
    version: '11'
    createMode: 'Default'
    // For remaining properties, see ServerPropertiesForCreate objects
  }
}

Upvotes: 1

Views: 1330

Answers (1)

Thomas
Thomas

Reputation: 29482

The error you received is related to the sku name:

The edition GeneralPurpose does not support the service objective Standard_D2s_v3

Looking at the documentation, the sku name has a specific naming convention:

The name of the sku, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8.

In you case, for general purpose it will be GP_GEN5_{number of cores}.

Upvotes: 1

Related Questions