Skip to content

Instantly share code, notes, and snippets.

@kayode-adechinan
Forked from davidsantiago-bib/PostgreSQL_azure.sh
Last active June 13, 2019 09:21
Show Gist options
  • Save kayode-adechinan/624e3cea1c9c8cc8ac03eb7997c9c837 to your computer and use it in GitHub Desktop.
Save kayode-adechinan/624e3cea1c9c8cc8ac03eb7997c9c837 to your computer and use it in GitHub Desktop.
# Create resource group named DjangoAppRG
$ az group create --name DjangoAppRG --location "West Europe"
# Create Azure Database for PostgreSQL server named pgdemoserver
$ az postgres server create --resource-group DjangoAppRG --name pgdemoserver --location westeurope --admin-user myadmin --admin-password ThisIs4P4ssw0rd!=1 --sku-name B_Gen5_1
# Allow access to Azure services
$ az postgres server firewall-rule create -g DjangoAppRG -s pgdemoserver -n allowall --start-ip-address 0.0.0.0 --end-ip-address 255.255.255.255
# not recommended
$ az postgres server update --resource-group DjangoAppRG --name pgdemoserver --ssl-enforcement Disabled
# Connect to the DB
$ psql --host=pgdemoserver.postgres.database.azure.com --port=5432 --username=myadmin@pgdemoserver --dbname=postgres
# Create Django database named djangodb
postgres=> CREATE DATABASE myproject;
postgres=> \q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment