How to fix {"message": "Internal Server Error" } when building flask rest api on top of synapse pool in azure apps

John Bronzo 21 Reputation points
2024-02-06T14:36:42.0866667+00:00

Hello, I am following this blog post: https://towardsdatascience.com/how-to-create-apis-on-top-of-synapse-serverless-sql-pools-f09e087400ab I have created the app locally and everything runs fine. I added one more stored procedure on the azure sql pool. After deploying the working app to the azure app service, I am receiving mentioned error on all 3 endpoints {"message": "Internal Server Error" }. After viewing log streams for the app it seems to be something with the connection string.

file "/tmp/8dc271de8c7010e/app.py", line 62, in __getConnection
2024-02-06T14:24:44.006171191Z     connstr = os.environ['SQLAZURECONNSTR_TAXI'] + ';Authentication=ActiveDirectoryMsi;

However, I have entered the proper connection string on azure app and gave app right on synapse sql pool to execute stored procedures. User's image

Azure Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
1,559 questions
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,373 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
0 comments No comments
{count} votes

Accepted answer
  1. Smaran Thoomu 24,110 Reputation points Microsoft External Staff Moderator
    2024-02-07T11:32:11.1766667+00:00

    Hi @John Bronzo ,

    Welcome to Microsoft Q&A forum and thanks for reaching out here.

    Based on the error message you provided, it seems that there is an issue with the connection string. Please ensure that the connection string is correct, and that the app has the necessary permissions to access the Synapse SQL pool.

    Here are a few things you can check:

    1. Verify that the connection string is correct and that it includes the correct credentials to access the Synapse SQL pool. You can check the connection string in the Azure portal by going to your App Service and navigating to Configuration > Application settings.
    2. Ensure that the app has the necessary permissions to access the Synapse SQL pool. You can check this by going to the Synapse workspace and navigating to Access control (IAM) > Role assignments. Make sure that the app has the necessary role assignments to access the SQL pool.
    3. Check the logs for any additional error messages that might provide more information about the issue. You can view the logs by going to your App Service and navigating to Log stream.
    4. Ensure that the stored procedure you added to the Synapse SQL pool is working correctly. You can test this by executing the stored procedure directly in the Synapse workspace.

    If you are still having issues, you can try updating the connection string in your code to include the username and password instead of using Active Directory authentication. You can also try using a different driver or library to connect to the Synapse SQL pool.

    I hope this helps! Let me know if you have any further questions.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.