Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
324 stars 56 forks source link

Add a "test connection" button in the Database Connection screen in Azure Portal #1299

Open sander1095 opened 11 months ago

sander1095 commented 11 months ago

Is your feature request related to a problem? Please describe. Debugging Static Web App's Database Connection feature (also known as Azure Data API Builder) is very very difficult because no information gets exposed about what is going wrong. I'm currently having this problem and it's described in detail at https://github.com/Azure/data-api-builder/issues/1814.

Locally everything works fine, but when deploying to Azure Static Web App it fails.

Describe the solution you'd like Currently the Azure Portal already mentions that the database needs to accept traffic and needs to allow traffic from other Azure Services. Why not add a "Test connection" button which performs a basic request to the Data Api Builder service (from the SWA) so the connection can be verified?

Maybe there could even be a 2nd button/popup that allows you to do a more advanced request that retrieves a specific entity, ensuring the entire chain should work.

If things do not work, more detailed debug information should be shown.

Describe alternatives you've considered Better debug information in the error messages from Azure Data Api Builder, though that probably doesn't belong here. Anyway, the button would be a lot more UX friendly.

Another alternative is not even requiring a button and testing the connection more thoroughly when a database connection is added so it should always work.

Additional context None

sander1095 commented 11 months ago

We might also want to add this as a CLI option

thomasgauvin commented 11 months ago

Noting the feedback & we're investigating how we could provide this option

sander1095 commented 11 months ago

Hi @thomasgauvin ! I'm thankful for this.

I'd like to say that I think it would be better to incorporate these "test connection" features into the database link process itself. Having it as an extra button means people might not press it and still be left confused about connections that aren't working. Integrating it into the linking process means that they won't be able to even link a non-working database.

I also just found out that linking a database with an incorrect SQL username/password still results in the database being linked, which (embarrassingly) is the root cause of https://github.com/Azure/data-api-builder/issues/1814.

I find this behaviour to be extremely odd. How can a database be linked if the credentials are incorrect?

TL;DR

When linking a database, do the following:

tdutch1 commented 8 months ago

Diagnostics and logging like what's been suggested is essential. I've seen a lot of posts and comments from those using DAB in SWA where the config works locally but not when deployed. If users can't troubleshoot then they'll contact support, who will then need to find a way to examine the config initialization within the SWA. Maybe require App Insights if using DAB and send all logs there?

Ticed commented 2 months ago

When linking the database and inputting the credentials, the password entered is wrapped by single quotes (i.e a password of ABC123 becomes 'ABC123'). Currently, there is no readily available documentation or troubleshooting to address this. It was only by running the command in the accepted solution on https://learn.microsoft.com/en-us/answers/questions/1198719/response-status-code-does-not-indicate-success-400 that I found out about this.

To solve it, ensure that your connection string within the staticwebapp.database.config.json file contains the quote-wrapped password, as any discrepancy will lead to HTTP 400.