- Check for Dependencies
Before you delete the server, make sure there are no dependent resources left behind that might be causing the portal to hang on “createdAt.” Common culprits include:
Geo-replicas or read replicas: If you configured geo-replication, you must break or delete the replica pair first.
Private endpoints: Any private endpoint interfaces bound to that server need to be removed (or dissociated) before you can delete the server.
Firewall / Virtual Network rules: These usually don’t block deletion, but it’s good to confirm nothing is locked in a weird state.
To check for replication relationships, go to:
Azure Portal → your PostgreSQL flexible server
“Replication” blade: If you see a replica in a different region or another server attached, click “Break replication” or delete the replica.
After breaking any replication links and removing private endpoints, give Azure a minute to update the server’s status.
- Delete via Azure CLI
Often the portal error goes away if you delete the server directly with the Azure CLI or Azure PowerShell. If you haven’t already, install the latest Azure CLI (≥ 2.45.0) or open the Azure Cloud Shell. Then run:
bash
Copy
# Log in (if you aren’t already):
az login
# Make sure you’re in the correct subscription:
az account set --subscription "<Your Subscription Name or ID>"
# Delete the Flexible Server:
az postgres flexible-server delete \
--resource-group MyResourceGroup \
--name MyFlexibleServerName \
--yes
--yes skips the interactive “Are you sure?” prompt.
If your server has a different name or RG, substitute accordingly.
If the server is in the “Deleting” or “Failed” state already, you can still force-delete it with the same command. The CLI call bypasses the portal’s JavaScript and will not try to read createdAt
from the portal’s UI objects.
- Delete via PowerShell (Alternative)
If you prefer PowerShell, you can do the equivalent:
powershell
Copy
# Install/Import the Az.PostgreSql module if needed:
Install-Module -Name Az.PostgreSql
Import-Module Az.PostgreSql
# Log in and select subscription:
Connect-AzAccount
Select-AzSubscription -SubscriptionName "MySubscriptionName"
# Delete the Flexible Server:
Remove-AzPostgreSqlFlexibleServer `
-ResourceGroupName "MyResourceGroup" `
-Name "MyFlexibleServerName" `
-Force
The -Force
parameter suppresses confirmation prompts. This cmdlet also bypasses the portal UI entirely.
- If You Still Can’t Delete
Verify the server’s provisioning state
In the Portal, navigate to Resource groups → YourRG → YourServer → Overview and look at “Provisioning state.”
If it’s stuck in “Failed” or “Deleting,” CLI/PowerShell should still succeed, but sometimes you need to wait 5–10 minutes for Azure’s backend to realize the dependencies have been removed.
**Check for Locks**
Go to **Resource groups → YourRG → Locks** and see if there is a “Delete” lock on the server or on the resource group.
If a delete lock exists, remove it (click the lock and delete).
**Check Activity Log**
In the Portal, open **Activity log** for that resource group.
Look for any recent “Delete” or “Failed” entries on the PostgreSQL server. If there’s a specific error (e.g. “Conflict” or “Resource locked”), it will show up here.
**Use the REST API as a Last Resort**
If CLI/PowerShell also fail with a similar JavaScript/undefined error (rare), you can issue a direct REST DELETE call against the resource URI:
```yaml
bash
Copy
DELETE https://management.azure.com/subscriptions/{subId}/resourceGroups/{rgName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}?api-version=2021-06-01
```
You can try this in Azure Cloud Shell with cURL or via Postman. Authenticate with a service principal or Azure AD token and then send the DELETE request. As long as there are no dependencies or locks, it will forcibly remove the server.
Summary
Remove any replicas or private endpoints attached to that Flexible Server.
Use Azure CLI:
bash
Copy
az postgres flexible-server delete --resource-group RG --name ServerName --yes
(or use the PowerShell equivalent).
If there’s still an error, confirm no locks are applied and check the Activity Log. As a final fallback, call the REST DELETE endpoint directly.
That approach always works around the portal-side “createdAt” JavaScript error. Once you’ve cleaned up any dependencies, the CLI/PowerShell deletion should succeed immediately.
- Check for Dependencies
Before you delete the server, make sure there are no dependent resources left behind that might be causing the portal to hang on “createdAt.” Common culprits include:
Geo-replicas or read replicas: If you configured geo-replication, you must break or delete the replica pair first.
Private endpoints: Any private endpoint interfaces bound to that server need to be removed (or dissociated) before you can delete the server.
Firewall / Virtual Network rules: These usually don’t block deletion, but it’s good to confirm nothing is locked in a weird state.
To check for replication relationships, go to:
Azure Portal → your PostgreSQL flexible server
“Replication” blade: If you see a replica in a different region or another server attached, click “Break replication” or delete the replica.
After breaking any replication links and removing private endpoints, give Azure a minute to update the server’s status.
- Delete via Azure CLI
Often the portal error goes away if you delete the server directly with the Azure CLI or Azure PowerShell. If you haven’t already, install the latest Azure CLI (≥ 2.45.0) or open the Azure Cloud Shell. Then run:
bash
Copy
# Log in (if you aren’t already):
--yes skips the interactive “Are you sure?” prompt.
If your server has a different name or RG, substitute accordingly.
If the server is in the “Deleting” or “Failed” state already, you can still force-delete it with the same command. The CLI call bypasses the portal’s JavaScript and will not try to read createdAt
from the portal’s UI objects.
- Delete via PowerShell (Alternative)
If you prefer PowerShell, you can do the equivalent:
powershell
Copy
# Install/Import the Az.PostgreSql module if needed:
Install-Module -Name Az.PostgreSql
Import-Module Az.PostgreSql
# Log in and select subscription:
Connect-AzAccount
Select-AzSubscription -SubscriptionName "MySubscriptionName"
# Delete the Flexible Server:
Remove-AzPostgreSqlFlexibleServer `
-ResourceGroupName "MyResourceGroup" `
-Name "MyFlexibleServerName" `
-Force
The -Force
parameter suppresses confirmation prompts. This cmdlet also bypasses the portal UI entirely.
- If You Still Can’t Delete
Verify the server’s provisioning state
In the Portal, navigate to Resource groups → YourRG → YourServer → Overview and look at “Provisioning state.”
If it’s stuck in “Failed” or “Deleting,” CLI/PowerShell should still succeed, but sometimes you need to wait 5–10 minutes for Azure’s backend to realize the dependencies have been removed.
**Check for Locks**
Go to **Resource groups → YourRG → Locks** and see if there is a “Delete” lock on the server or on the resource group.
If a delete lock exists, remove it (click the lock and delete).
**Check Activity Log**
In the Portal, open **Activity log** for that resource group.
Look for any recent “Delete” or “Failed” entries on the PostgreSQL server. If there’s a specific error (e.g. “Conflict” or “Resource locked”), it will show up here.
**Use the REST API as a Last Resort**
If CLI/PowerShell also fail with a similar JavaScript/undefined error (rare), you can issue a direct REST DELETE call against the resource URI:
```yaml
bash
Copy
DELETE https://management.azure.com/subscriptions/{subId}/resourceGroups/{rgName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}?api-version=2021-06-01
```
You can try this in Azure Cloud Shell with cURL or via Postman. Authenticate with a service principal or Azure AD token and then send the DELETE request. As long as there are no dependencies or locks, it will forcibly remove the server.
That approach always works around the portal-side “createdAt” JavaScript error. Once you’ve cleaned up any dependencies, the CLI/PowerShell deletion should succeed immediately.
Hope that helps.