Azure Postgresql Flexible Server taking too long to deploy, stucked in "Deployment is in progress".

Krunal Fijiwala 0 Reputation points
2024-09-19T08:11:00.9433333+00:00

Hello,

I'm trying to provision a publicly accessible postgresql flexible server of burstable compute B1ms in East US 2 region using Azure Portal. After almost 2 hours since I started creation of the server, first it was stucked in "Deployment is in progress" state and then failed with

"The resource write operation failed to complete successfully, because it reached terminal provisioning state 'Failed'. (Code: ResourceDeploymentFailure, Target: /subscriptions/c14a8c32-f507-4a34-ad05-fc33fc24dfb8/resourceGroups/taxmatrix-dev RG/providers/Microsoft.DBforPostgreSQL/flexibleServers/test)".

I also tried using terraform and azure CLI but that also failed. Not getting any good results trying to provision Azure Postgresql Flexible Server.

Can anyone help me with this?

Thanks

Azure Database for PostgreSQL
{count} votes

1 answer

Sort by: Most helpful
  1. ShaktiSingh-MSFT 15,321 Reputation points
    2024-09-19T09:48:02.9233333+00:00

    Hi Krunal Fijiwala •,

    Welcome to Microsoft Q&A forum.

    As I understand, your deployment of Azure Database for PostgreSQL Flexible Server is failing.

    • When creating a server using Terraform, make sure depends-on is used with configuration, firewall, or creating databases, for instance: Flexible server: If you're using a default template from a Terraform flexible server , you'll need to add depends_on for virtual networks and private DNS zones if the server is created with private access .
            resource "azurerm_postgresql_flexible_server" "example" {
                  name                   = "example-psqlflexibleserver"
                  resource_group_name    = azurerm_resource_group.example.name
                  location               = azurerm_resource_group.example.location
                  version                = "12"
                  delegated_subnet_id    = azurerm_subnet.example.id
                  private_dns_zone_id    = azurerm_private_dns_zone.example.id
                  administrator_login    = "psqladmin"
                  administrator_password = "H@Sh1CoR3!"
                  zone                   = "1"
    
                  storage_mb = 32768
    
                  sku_name   = "GP_Standard_D4s_v3"
                  depends_on = [azurerm_private_dns_zone_virtual_network_link.example]
    
                } 
    

    If you're doing multiple configurations, for instance, updating a firewall and changing parameters , make sure to add depends_on when changing the parameters for the firewall update if the firewall was the first change on the server.

        resource "azurerm_postgresql_flexible_server_configuration" "example" {
            name      = "backslash_quote"
            server_id = azurerm_postgresql_flexible_server.example.id
            value     = "on"
    
            
            depends_on = [azurerm_postgresql_flexible_server_firewall_rule.example]
            }
    ```The parallelism  default in Terraform is 10. Try to run Terraform without it: terraform apply parallelism =1.
    
    Avoid relying on implicit dependencies, and utilize explicit dependencies. See the examples under number 1 of this section.
    
    When configuring high availability, use ignore-changes in Terraform to avoid running a failover:
    
    ```powershell
            resource "azurerm_postgresql_flexible_server" "example" {
              name                   = "server_name"
              resource_group_name    = "terraform"
              location               = "West Europe"
              version                = "12"
              administrator_login    = "adminuser"
              administrator_password = "H@Sh1CoR33"
              sku_name               = "GP_Standard_D2ds_v4"
    
              storage_mb = 32768
    
            lifecycle {
                  ignore_changes = [
                    zone,
                    high_availability.0.standby_availability_zone
                  ]
              }
            }
    

    Additional troubleshooting

    If you're still seeing errors in Terraform deployments after using depends_on and disabling parallelism, try the following.

    Create a server as follows:

    resource "azurerm_postgresql_flexible_server" "example" {
      name                   = "testflexible"
      resource_group_name    = "testgroup"
      location               = azurerm_resource_group.example.location
      version                = "12"
      administrator_login    = "psqladmin"
      administrator_password = "H@Sh1CoR3!"
    
      storage_mb = 32768
    
      sku_name = "GP_Standard_D4s_v3"
    }
    

    After the server is created, then add firewall rules and server configuration . You can debug Terraform .

    In PowerShell run:

    $env:TF_LOG="TRACE"
    In bash/linux shell
    export TF_LOG="TRACE"
    

    Additionally, try below if that helps:- create the server with unique name.

    • Deleting the nested resources i.e. Private DNS zone which was created from previous deployment.
    • Above are the possible reasons for Azure Database for PostgreSQL Flexible provisioning errors. There may be other scenarios also for failed provisioning.

    Issue : Failing with error Server name 'name.postgres.database.azure.com ' already exists please choose a different name.

    Let us know if this helped.

    Awaiting your reply.

    Thanks

    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.