Coder Perfect

How can I use Bicep to generate Microsoft.DBforPostgreSQL?

Problem

I’d like to write PostgreSQL to meet the needs of location-based services. Next, I’d set up GIS extensions.

To determine the correct configuration, I manually constructed an Azure Database for PostgreSQL flexible server. “sku”: “name”: “Standard B1ms”,”tier”: “Burstable” “sku”: “name”: “Standard B1ms”,”tier”: “Burstable” I wanted to make a Single server, but for some reason it wasn’t available in Europe. Missing Burstable seems like a decent idea for an early POC, but general purpose is also a wonderful idea.

Bicep is now being used to construct PostgreSQL. However, I’m having trouble setting up a valid server. Burstable, for starters, was unavailable. After that, I’m unable to enter a proper sku name.

build an az deployment group:

{"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
  }
}

Asked by Kenny_I

Solution #1

The following is the sku name that caused the error:

The edition GeneralPurpose does not support the service objective Standard_D2s_v3

The sku name follows a certain naming convention, according to the documentation:

GP GEN5 number of cores will be GP GEN5 number of cores in your case.

Answered by Thomas

Post is based on https://stackoverflow.com/questions/70291539/how-to-create-microsoft-dbforpostgresql-with-bicep