After you create a new Azure Database for PostgreSQL server, your next steps are to set up your Postgres users, databases, extensions and more. An ARM template can help you automate both the server creation and running a startup script. This is ideal for automation scenarios in which you create one or more servers with a fixed configuration and pre-loaded databases, users, roles etc. We can create a reproducible SQL script that can be run after server creation to initialize the server. This SQL script can contain steps like create database, create users, configure roles, create tables, load data, manage extensions etc.
Now, we provide a mechanism to run this initialization SQL script as part of the ARM Template deployment itself : ExampleWithStartupScript
To add your own init.sql steps, please fork the repository, modify the init.sql file to include your custom steps and then deploy using the following link (Replace <GITHUB_USERNAME> with your github handle) :
NOTE: After successful deployment, you may either use the Ubuntu VM as a PG client VM or delete it.
If you have trouble running the script, please let us know by opening an issue here.
Also, feel free to contribute any updates or bug fixes by creating a pull request.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.