Using Azure Cosmos DB for PostgreSQL & Hasura GraphQL
How to get started:
- Sign up for a Hasura Cloud account
- Create a project in the Hasura Cloud Account
- Sign up for the Azure Cosmos DB free trial and select Azure Cosmos DB for PostgreSQL
- Once you have completed the sign up for the trial on Azure, this will bring you to the Azure portal
Connecting Azure Cosmos DB to Hasura
- In the menu on the left in the Azure Portal, select Connection Strings
- Copy the PostgreSQL connection URL, we will use this to place in our Hasura Project.
- In your Hasura cloud account, edit your project settings and select Env vars.
- Add a new Env var called DATABASE_URL and paste your connection URL into the value.
- Replace the {your_password} with the password you created when resetting the database.
- Save your env variable.
- Now we can launch our Hasura Console by clicking Launch Console in the top right.
- Go to the Data tab in the Hasura Console.
- Click Connect Database
- Give the database a name and select Data Source Driver of Citus.
- Select Environment Variable for the Connect Database Via setting.
- Enter the Environment Variable of DATABASE_URL
Building your Database
Why Azure Cosmos DB for PostgreSQL?
- True PostgreSQL - Microsoft maintains this product with the latest version of PostgreSQL within two weeks of each release.
- Managed Cloud Database - Being built on Azure's managed services, you can take the worry out of managing databases. Microsoft Azure provides high availability configurations across availability zones.
- Powered by Citus - You can simply start with a small Free Trial and grow it into a highly scalable database with distributed tables. This will handle building a relational database at scale with distributed transactions, deadlocks, foreign keys, and more.
- Global Availability - Because Azure Cosmos DB for PostgreSQL is powered by Cosmos DB, you can choose to distribute your database globally with just a few clicks of a button.
Conclusion
Related reading