Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
404 stars 195 forks source link

Add retries for `sqlcmd` in sqlserver.bicep #2098

Open weikanglim opened 1 year ago

weikanglim commented 1 year ago

Problem

sqlcmd (relevant code here) often fails to connect to the newly provisioned database when azd provision runs, with error:

"Database '<>' is not currently available. Please retry this connection later."

Example failures:

Fix

  1. We should add retries for failure conditions in the deployment script, and timeout after 3-5 minutes.
  2. We should investigate if sqlcmd is logging errors to standard out or standard error, and if there's something we can change here. The logs from sqlcmd are not showing up in the github action logs, which are first parsed by Microsoft.Resources/deploymentScripts service. There should be a way to get the logs to show up and avoid the extra step of troubleshooting for the user.
rajeshkamal5050 commented 1 year ago

@jongio can you take a look and see if we can

jongio commented 1 year ago

Retries being discussed here: https://github.com/Azure/bicep/issues/1013

You can try to add a depends on for the database.