Azure PostgreSQL: it is not possible to remove database through Azure CLI

时光毁灭记忆、已成空白 提交于 2019-12-11 16:01:46

问题


I have created pipeline using Azure DevOps for Azure PostgreSQL database.

What actually pipeline do?

  1. Connect to PostgreSQL;
  2. Remove database db_test from PostgreSQL using Azure CLI;

az postgres db delete -g my_group -s database_here -n db_test --yes

However, I cannot do this due to error:

An unexpected error occured while processing the request.

Then, I was trying to remove the database using psql, but with no luck due to existing connections to database.

From my point of view - Azure CLI must handle such issues and remove database or pass correct error message to me. For example it would be great if parameter --force will be implemented.

I have removed all connections to database using the following syntax in a bash script:

psql "host=database_here port=5432 dbname=postgres user=postgres@database_here password=ReallyStrongPassword sslmode=require" -c "REVOKE CONNECT ON DATABASE db_test FROM PUBLIC; SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'db_test';"

and added DROP database action additionally to my pipeline:

psql "host=database_here port=5432 dbname=postgres user=postgres@database_here password=ReallyStrongPassword sslmode=require" -c "DROP database db_test;"

But I didn't remove AZ CLI database removal step from pipeline and it has failed with the following output:

Operation failed with status: 200. Details: Resource state Failed

I think on this step, AZ CLI should return something like: "Database does not exist." just as informative message.

How to properly handle such situations on the Azure side?


回答1:


Does az postgres db show show the database details? Please check if this is happening due to this behaviour, albeit the discussion in the quoted thread is in context with a SQL database.

If the issue still persists, please feel free to drop your feedback here open an issue with our GitHub repo for our internal Team to take a look at.

Thanks for the feedback!



来源:https://stackoverflow.com/questions/58268141/azure-postgresql-it-is-not-possible-to-remove-database-through-azure-cli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!