Hi @vijay ande , thanks for reaching out to us. Please refer below for more details.
1) For migrating from On-Premise to Azure Database for PostgreSql, you can utilize the 'Azure Database Migration Services' service. below article has step by step process of doing the same.
https://learn.microsoft.com/en-us/azure/dms/tutorial-rds-postgresql-server-azure-db-for-postgresql-online
You can also achieve the same using Azure CLI, please refer below article which is very straight forward and if this is one time activity, you can prefer this approach too.
https://learn.microsoft.com/en-us/azure/dms/tutorial-postgresql-azure-postgresql-online
2) For migrating from Azure Database for PostgreSql to on-premise, there is no service or tool handy but below is the article you can refer to. Here we create a .sql dump file from Azure Postgresql database and then you can import the dump .sql file in your on-premise database.
https://techcommunity.microsoft.com/t5/azure-database-for-postgresql/backup-azure-database-for-postgresql-to-a-blob-storage/ba-p/803343
You can also use the Azure Data Factory to achieve the desired functionality as well:
https://learn.microsoft.com/en-us/azure/data-factory/connector-azure-database-for-postgresql
Please let us know if you have any query or looking for some more details.