How to implement Retry Policy on GraphQL API in Azure APIM on Database Connectivity Error
I am looking for help implementing a Retry Policy for Azure GraphQL API with a backend of Azure SQL DB. The SQL DB is serverless and auto-pause enabled, which can cause some delay in wake-up times.
Previously, with REST API + Function App, I received proper HTTP codes (HTTP 500 or HTTP 503 backend) and could implement a retry policy at Azure API Management Backend.
However, I am now using a GraphQL API to connect Azure SQL DB directly and receiving error details in the response body with HTTP response code 200 OK.
Can someone help me implement retry policy to check and retry if the message contains SQL Error code 40613? Here is an example of the response code:
{
"errors": [
{
"message": "SQL exception received when resolving value for path Query/getAllEmployeeDetailsChangedEvent",
"extensions": {
"code": "GQL_CUSTOMRESOLVER_ERROR",
"codes": [
"GQL_CUSTOMRESOLVER_ERROR"
],
"data": {
"message": "SQL exception received from SQL server/database. For details, match SQL error number to 'Database Engine errors' documentation. sqlSource: Framework Microsoft SqlClient Data Provider, sqlErrorNumber: 40613",
"path": "Query/getAllEmployeeDetailsChangedEvent",
"source": "sql-graphql-resolver",
"innerException": "Database 'db_azsql-ctn-ais-d-ae-01' on server 'azsql-ctn-ais-d-ae-01.database.windows.net' is not currently available. Please retry the connection later. If the problem persists, contact customer support, and provide them the session tracing ID of '{D20D1031-1B05-4E0A-9441-D635C3668DB4}'."
}
}
}
],
"data": {
"getAllEmployeeDetailsChangedEvent": null
}
}
Thank you for any help you can provide.
Best regards,
Ayan Bhattacharyya