Not able to delete the Azure Database for PostgreSQL flexible servers

Mahesh 45 Reputation points
2025-05-30T10:44:19.7333333+00:00

Hi,

I had a PostgreSQL flexible server provisioned with Terraform, which I am trying to remove. Initially, I attempted to do so with' terraform destroy', but it timed out after 60 minutes, and the server did not get completely deleted. Now In Azure portal I am still able to see the database server but when I open it, I am not able to see all the details and also not able to dlete it from the portal, I also tried with az CLI, az postgres flexible-server list --resource-group resource-group
I can list the database, but not delete it.
➜ az postgres flexible-server delete --name krisatwork-dev-postgres-db --resource-group resource-group

Are you sure you want to delete the server 'krisatwork-dev-postgres-db' in resource group 'kaw-dev-datastore' (y/n): y

(ResourceNotFound) The requested resource of type 'Microsoft.DBforPostgreSQL/flexibleServers' with name 'krisatwork-dev-postgres-db' was not found.

Code: ResourceNotFound User's image

User's image

Community Center Not monitored
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Obinna Ejidike 1,835 Reputation points
    2025-06-02T11:45:52.26+00:00

    Hi Mahesh

    Thanks for using the Q&A platform.

    It seems you're dealing with a stuck deletion state for your Azure PostgreSQL Flexible Server. It's showing as "Dropping" in the portal, yet neither Terraform destroy nor Az Postgres Flexible Server delete can fully remove it. This usually happens when a resource enters a “zombie” state due to incomplete deletion.

    Can you verify the deletion status using Azure Resource Graph using the below command:

    az graph query -q "Resources | where name == 'krisatwork-dev-postgres-db' and type =~ 'microsoft.dbforpostgresql/flexibleservers'"
    

    If the result is empty, the resource is already logically gone, but metadata may be stuck.

    You can also use the following document to adjust your query: https://learn.microsoft.com/en-us/azure/governance/resource-graph/concepts/query-language

    Also, you can try force deletion using the Azure REST API:

    az rest --method delete \
      --url https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/kaw-dev-datastore/providers/Microsoft.DBforPostgreSQL/flexibleServers/krisatwork-dev-postgres-db?api-version=2023-06-01-preview
    

    Find Microsoft documentation: https://learn.microsoft.com/en-us/cli/azure/use-azure-cli-rest-command?view=azure-cli-latest&tabs=bash#use-delete-to-delete-your-azure-container-registry

    If the issue persists, you can also seek help from Microsoft Azure support to help with running a backend cleanup to fully remove it.

    You can mark it 'Accept Answer' and 'Upvote' if this helped you

    Regards,

    Obinna

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.