Hi Jack Roman,
Greetings!
It sounds like you're encountering some common issues with permissions and resource referencing in Azure PostgreSQL Flexible Server deployments using Bicep.
Here are a few steps to help you automate the creation of a database within the server.
1.You can use Bicep to create the database as a child resource of the PostgreSQL server. Here's a simplified example of how you can define the server and the database in your Bicep file:
param administratorLogin string
@secure()
param administratorLoginPassword string
param ___location string = resourceGroup().___location
param serverName string
param databaseName string
resource server 'Microsoft.DBforPostgreSQL/flexibleServers@2021-06-01' = {
name: serverName
___location: ___location
properties: {
administratorLogin: administratorLogin
administratorLoginPassword: administratorLoginPassword
version: '12'
}
}
resource database 'Microsoft.DBforPostgreSQL/flexibleServers/databases@2021-06-01' = {
parent: server
name: databaseName
properties: {
charset: 'UTF8'
collation: 'en_US.UTF8'
}
}
2.Deploy the Bicep file using Azure CLI to ensure the resources are created correctly:
az group create --name exampleRG --___location centralus
az deployment group create --resource-group exampleRG --template-file main.bicep
3.Sometimes, creating the resources manually in the Azure Portal can help identify any missing configurations or permissions.
For more information, please refer the document:
https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/quickstart-create-server-bicep?tabs=CLI
You can automatically deploy your database updates to Azure Database for PostgreSQL flexible server after every successful build with Azure Pipelines. You can use Azure CLI task to update the database either with a SQL file or an inline SQL script against the database.
For more information, please refer the document:
Hope this helps. Do let us know if you any further queries.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.