Database queries yield "InternalServerError"
- Dominant language
- No language data
- Stars
- 346
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Connected a database to our Azure Static Web App using the Azure portal.
2. Every GraphQL query returns something along the lines of: {"Message":"InternalServerError","ActivityId":"781044af-27f1-49ef-a77f-c1ae5656f72e"}
4. Locally it works if we run a command like `swa start ./src --swa-config-location config/local --data-api-location swa-db-connections/ --api-location api/ --run \"npm run start\"`
5. The code we use is synchronized with the production SWA using Github Actions (the integration was selected in the portal when setting up the SWA).
One annoying thing is, it just worked a few hours ago. However, I didn't change the configuration of the SWA, database or its connection.
Github Actions workflow YAML file:
```
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: "api" # Api source code path - optional
output_location: "build" # Built app content directory - optional
###### End of Repository/Build Configurations ######
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
action: "close"
```
staticwebapp.config.json:
```
{
"navigationFallback": {
"rewrite": "/index.html",
"exclude": ["*.{css,scss,js,png,gif,ico,jpg,svg}"]
},
"responseOverrides": {
"401": {
"statusCode": 302,
"redirect": "/.auth/login/aadb2c"
}
},
"routes": [
{
"route": "/.auth/login/aadb2c",
"allowedRoles": ["anonymous"]
},
{
"route": "/login*",
"allowedRoles": ["anonymous"],
"rewrite": "/.auth/login/aadb2c"
},
{
"route": "/logout*",
"allowedRoles": ["authenticated"],
"rewrite": "/.auth/logout?post_logout_redirect_uri=/login"
},
{
"route": "/.auth/me",
"allowedRoles": ["authenticated", "anonymous"]
},
{
"route": "/*",
"allowedRoles": ["authenticated"]
}
],
"auth": {
"identityProviders": {
"customOpenIdConnectProviders": {
"aadb2c": {
"registration": {
"clientIdSettingName": "AADB2C_PROVIDER_CLIENT_ID",
"clientCredential": {
"clientSecretSettingName": "AADB2C_PROVIDER_CLIENT_SECRET"
},
"openIdConnectConfiguration": {
"wellKnownOpenIdConfiguration": "..."
}
},
"login": {
"nameClaimType": "emails",
"scopes": ["openid"]
}
}
}
}
}
}
```
staticwebapp.database.config.json:
```
{
"$schema": "https://github.com/Azure/data-api-builder/releases/latest/download/dab.draft.schema.json",
"data-source": {
"database-type": "mssql",
"connection-string": "@env('DATABASE_CONNECTION_STRING')",
"options": {
"set-session-context": true
}
},
"runtime": {
"rest": {
"enabled": true,
"path": "/rest",
"request-body-strict": true
},
"graphql": {
"enabled": true,
"path": "/graphql",
"allow-introspection": true
},
"host": {
"cors": {
"origins": [
"http://localhost:4280"
],
"allow-credentials": false
},
"authentication": {
"provider": "StaticWebApps"
},
"mode": "production"
}
},
"entities": {
...
}
}
```
**Expected behavior**
The GraphQL queries should return their results. Important: **running it locally, it works**.
**Device info (if applicable):**
- Browser: Chrome
- Version: Local CLI is 1.1.4
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.