You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This documentation enhancement will guide you through resolving common issues with linking an Azure SQL Database to a Static Web App (SWA) using Astro, focusing on configuration and troubleshooting.
Prerequisites
An Azure SQL Database instance with necessary tables and data.
An Azure Static Web App created using Astro.
Access to the Azure Portal.
Steps to Configure and Resolve Issues
1. Configure the staticwebapp.database.config.json
Ensure your configuration file is correctly set up with:
This documentation enhancement will guide you through resolving common issues with linking an Azure SQL Database to a Static Web App (SWA) using Astro, focusing on configuration and troubleshooting.
Prerequisites
Steps to Configure and Resolve Issues
1. Configure the
staticwebapp.database.config.json
Ensure your configuration file is correctly set up with:
Example:
2. Allow Azure Resources and Configure Database Access
3. Test Connection Locally
Run the Static Web App locally with the Data API:
swa start . --data-api-location swa-db-connections
Use REST or GraphQL paths to verify data retrieval:
http://localhost:<port>/data-api/rest/Test
4. Deployment to Azure
Push your configuration and application code to GitHub. Azure SWA will use the deployment pipeline defined in the GitHub Action workflow.
Ensure your YAML file specifies:
dist
location for the app.5. Common Issues and Troubleshooting
Server
,Database
,User ID
,Password
) are correctly populated.cors.origins
is set to["*"]
for debugging. Restrict it later for production.source
matches the table name in your Azure SQL Database.6. Example Output
After resolving issues, accessing
/data-api/rest/Test
should return data like:GraphQL queries will also function correctly via
/data-api/graphql
.References
By following these steps, you should be able to resolve connectivity issues and successfully integrate an Azure SQL Database with your Static Web App.
The text was updated successfully, but these errors were encountered: