Azure PostgreSQL:无法通过Azure CLI删除数据库 [英] Azure PostgreSQL: it is not possible to remove database through Azure CLI

查看:139
本文介绍了Azure PostgreSQL:无法通过Azure CLI删除数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Azure DevOps for Azure PostgreSQL数据库创建了管道.

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

管道的实际作用是什么?

What actually pipeline do?

  1. 连接到PostgreSQL;
  2. 使用Azure CLI从PostgreSQL删除数据库db_test;

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

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.

然后,我试图使用psql删除数据库,但是由于与数据库的现有连接而没有运气.

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

从我的角度来看-Azure CLI必须处理此类问题并删除数据库或向我传递正确的错误消息.例如,如果将实现参数--force,那就太好了.

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.

我已在bash脚本中使用以下语法删除了与数据库的所有连接:

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';"

并在我的管道中添加了DROP数据库操作:

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;"

但是我没有从管道中删除AZ CLI数据库删除步骤,但它失败,并显示以下输出:

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

我认为在此步骤中,AZ CLI应该返回类似以下内容:数据库不存在".就像信息一样.

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

如何在Azure方面正确处理此类情况?

How to properly handle such situations on the Azure side?

推荐答案

az postgres db show是否显示数据库详细信息?请检查是否由于行为而发生引号中的讨论是在SQL数据库中进行的.

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.

如果问题仍然存在,请随时放弃您的反馈 GitHub存储库 a>让我们的内部团队来看看.

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.

感谢您的反馈!

这篇关于Azure PostgreSQL:无法通过Azure CLI删除数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆