Azure-Samples / contoso-real-estate

Intelligent enterprise-grade reference architecture for JavaScript, featuring OpenAI integration, Azure Developer CLI template and Playwright tests.
MIT License
858 stars 512 forks source link

[Chore] Postgresql failed to restore in `azd provision` #419

Closed dfberry closed 7 months ago

dfberry commented 8 months ago

Are you accessing the project from the GitHub Codespaces?

Note: The project is optimized to run on Codespaces. We welcome contributions to enhance it for cross-platform local development, but it's not something we will prioritize right now. Thank you!

Describe the bug azd provision didn't complete successfully, the postgresql restore failed with pg_restore: connecting to database for restore pg_restore: error: connection to server at "psql-db-hgraruq6pioo4.postgres.database.azure.com" (40.123.42.110), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections?

To Reproduce Steps to reproduce the behavior:

  1. Fresh clone from current commit 4dbd1fba807300650bd8eec5707be5d1d773e8ba to mac m1
  2. open in vscode
  3. reopen in dev container
  4. azd auth login
  5. azd provision
  6. View DB from Azure portal which add firewall rule
  7. Change .env value for restore to false so I can rerun script
  8. Rerun script and it works
  9. Assume the firewall rule is the missing/incorrect step.

Expected behavior No errors during provision

Screenshots image

OS (please complete the following information):

Additional context The next line after the error says the restore succeeded. So I can't rerun the restore without changing the value in the .env file for the environment.

Using the Azure Portal connect to database, then using psql command \dt, the response was Did not find any relations.

? Enter a new environment name: dfberry-contoso-20231220

Provisioning Azure resources (azd provision)
Provisioning Azure resources can take some time.

  (✓) Done: Downloading Bicep
? Select an Azure Subscription to use:  3. Visual Studio Enterprise Subscription (b57b253a-e19e-4a9c-a0c0-a5062910a749)
? Select an Azure location to use: 43. (US) East US 2 (eastus2)
Subscription: Visual Studio Enterprise Subscription (b57b253a-e19e-4a9c-a0c0-a5062910a749)
Location: East US 2

  You can view detailed progress in the Azure Portal:
  https://portal.azure.com/#view/HubsExtension/DeploymentDetailsBlade/~/overview/id/%2Fsubscriptions%2Fb57b253a-e19e-4a9c-a0c0-a5062910a749%2Fproviders%2FMicrosoft.Resources%2Fdeployments%2Fdfberry-contoso-20231220-1703093656

  (✓) Done: Resource group: rg-dfberry-contoso-20231220
  (✓) Done: App Service plan: plan-hgraruq6pioo4
  (✓) Done: Static Web App: stapp-web-hgraruq6pioo4
  (✓) Done: Key Vault: kv-hgraruq6pioo4
  (✓) Done: Log Analytics workspace: log-hgraruq6pioo4
  (✓) Done: Storage account: sthgraruq6pioo4
  (✓) Done: Application Insights: appi-hgraruq6pioo4
  (✓) Done: Portal dashboard: dash-hgraruq6pioo4
  (✓) Done: Container Registry: crhgraruq6pioo4
  (✓) Done: Container Apps Environment: cae-hgraruq6pioo4
  (✓) Done: Azure Cosmos DB: cosmos-hgraruq6pioo4
  (✓) Done: Azure Database for PostgreSQL flexible server: psql-db-hgraruq6pioo4
  (✓) Done: Function App: func-api-hgraruq6pioo4
  (✓) Done: Container App: ca-cms-hgraruq6pioo4
  (✓) Done: Container App: ca-blog-hgraruq6pioo4
  (✓) Done: Container App: ca-stripe-hgraruq6pioo4
Getting values from azd
Restoring PostgreSQL Database from /workspaces/contoso-real-estate/scripts/database/dumps/strapi_20230922.sql
pg_restore: connecting to database for restore
pg_restore: error: connection to server at "psql-db-hgraruq6pioo4.postgres.database.azure.com" (40.123.42.110), port 5432 failed: Connection refused
        Is the server running on that host and accepting TCP/IP connections?
PostgreSQL Database restored successfully
Setting STRAPI_DATABASE_MIGRATED to true in azd

SUCCESS: Your application was provisioned in Azure in 6 minutes 16 seconds.
You can view the resources created under the resource group rg-dfberry-contoso-20231220 in Azure Portal:
https://portal.azure.com/#@/resource/subscriptions/b57b253a-e19e-4a9c-a0c0-a5062910a749/resourceGroups/rg-dfberry-contoso-20231220/overview
diberry commented 7 months ago

Haven't seen this in a while.

manekinekko commented 7 months ago

Tried a fresh install today, didn't encouter it neither.