0

Bicep version

Bicep CLI version 0.3.255 (589f037)

Describe the bug

I am trying to set an Active Directory Admin for an PostgreSQL server via Bicep. I am able to create the PostgreSQL server but there is no documentation regarding a type for example resource postgresqlActiveDirectoryAdmin 'Microsoft.DBforPostgreSQL/servers/administrators@2017-12-01'. So I decided to export an ARM template of a resource which had set an admin manually, and decompile this into a bicep template.

The error that is being thrown is a Bad Request:

{
    "status": "Failed",
    "error": {
        "code": "InvalidResourceIdSegment",
        "message": "The 'parameters.properties' segment in the url is invalid.",
        "details": [
            {
                "code": "InvalidResourceIdSegment",
                "target": "parameters.properties",
                "message": ""
            }
        ]
    }
}

To Reproduce Simply create the PostgreSQL server in Bicep and attempt to add an administrator for example:

resource postgreSQL 'Microsoft.DBforPostgreSQL/servers@2017-12-01' = {
  name: serverName
  identity: {
    type: 'SystemAssigned'
  }
  sku: {
    name: 'B_Gen5_1'
    tier: 'Basic'
    capacity: 1
    family: 'Gen5'
  }
  properties: {
    version: '11'
    sslEnforcement: 'Enabled'
    minimalTlsVersion: 'TLSEnforcementDisabled'
    infrastructureEncryption: 'Disabled'
    publicNetworkAccess: 'Enabled'
    storageProfile: {
      backupRetentionDays: 7
      geoRedundantBackup: 'Disabled'
      storageMB: 5120
      storageAutogrow: 'Disabled'
    }
    createMode: 'Default'
    administratorLogin: 'adminName'
    administratorLoginPassword: 's3cur3p455w0rd!' 
  }
  location: 'uksouth'
  tags: {}
  //resources: [] 
}


resource postgresqlActiveDirectoryAdmin 'Microsoft.DBforPostgreSQL/servers/administrators@2017-12-01' = {
  parent: postgreSQL
  name: 'activeDirectory'
  properties: {
    administratorType: 'ActiveDirectory'
    login: 'PostgresAdmin' //This is a Group in the Azure Directory
    sid: 'xxxxxxx' //grab SID(object id) of the group
    tenantId: 'xxxx' //tenant id
  }
}

Nothing really mentioned in documentation so just relying on some knowledge on if this is possible currently?

Thomas
  • 24,234
  • 6
  • 81
  • 125
ScuffedCoder
  • 376
  • 1
  • 5
  • 21

1 Answers1

0

It is possible and worked fine for me (even if the deployment took around 10min):

param serverName string

resource postgreSQL 'Microsoft.DBforPostgreSQL/servers@2017-12-01' existing = {
  name:serverName
}

resource postgresqlActiveDirectoryAdmin 'Microsoft.DBforPostgreSQL/servers/administrators@2017-12-01' = {
  name: 'activeDirectory'
  parent: postgreSQL
  properties: {
    administratorType: 'ActiveDirectory'
    login: 'PostgresAdmin' //This is a Group in the Azure Directory
    sid: 'xxxxxxx' //grab SID(object id) of the group
    tenantId: 'xxxx' //tenant id
  }
}
Thomas
  • 24,234
  • 6
  • 81
  • 125