File "src/pymssql/_pymssql.pyx", line 659, in pymssql._pymssql.connect 2024-10-24T08:02:45.5167672Z sqlalchemy.exc.OperationalError: (pymssql.exceptions.OperationalError) (40613, b"Database 'pv_Ai_Sql' on server 'propvivoai.database.windows.net' is not cu

Anshuman Srivastava 10 Reputation points
2024-10-24T12:33:09.0633333+00:00

i have deployed my fast api on app service using container registry so in my deployment settings logs are shoing this error
"File "src/pymssql/_pymssql.pyx", line 659, in pymssql._pymssql.connect 2024-10-24T08:02:45.5167672Z sqlalchemy.exc.OperationalError: (pymssql.exceptions.OperationalError) (40613, b"Database 'pv_Ai_Sql' on server 'propvivoai.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 '{DB5156B1-4880-4696-B44B-E29D60664210}'.DB-Lib error message 20018, severity 20:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (propvivoai.database.windows.net)\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (propvivoai.database.windows.net)\n") where is this File "src/pymssql/_pymssql.pyx", line 659, is present"

where as my sql database is running(in running state i have check the matrix of availability also) perfectly all the connection strings are correct
actually it is working perfectly as i pushs my new changes it is showing this error but on local my project is running without showing any error
when i am running my app service it is showing the page as i attached with this ticket

i am also attaching my requirement file for your reference

aiohttp==3.9.3
aiosignal==1.3.1
alembic==1.13.2
annotated-types==0.6.0
anyio==4.3.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
attrs==23.2.0
azure-ai-documentintelligence==1.0.0b1
azure-core==1.31.0
azure-identity==1.19.0
bcrypt==4.1.2
blis==0.7.11
cachetools==5.5.0
catalogue==2.0.10
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
cloudpathlib==0.16.0
confection==0.1.4
cryptography==42.0.5
cymem==2.0.8
dataclasses-json==0.6.4
distro==1.9.0
ecdsa==0.19.0
environs==9.5.0
fastapi==0.110.0
frozenlist==1.4.1
google-api-core==2.20.0
google-auth==2.35.0
googleapis-common-protos==1.65.0
greenlet==3.0.3
grpcio==1.60.0
grpcio-tools==1.60.0
h11==0.14.0
httpcore==1.0.4
httptools==0.6.1
httpx==0.27.0
idna==3.6
isodate==0.6.1
Jinja2==3.1.3
jsonpatch==1.33
jsonpointer==2.4
langchain==0.1.9
langchain-community==0.0.24
langchain-core==0.1.28
langchain-openai==0.0.8
langcodes==3.3.0
langsmith==0.1.10
Mako==1.3.5
MarkupSafe==2.1.5
marshmallow==3.21.0
minio==7.2.4
msal==1.31.0
msal-extensions==1.2.0
multidict==6.0.5
murmurhash==1.0.10
mypy-extensions==1.0.0
numpy==1.26.4
openai==1.13.3
opencensus==0.11.4
opencensus-context==0.1.3
opencensus-ext-azure==1.1.13
orjson==3.9.15
packaging==23.2
pandas==2.2.1
passlib==1.7.4
portalocker==2.10.1
preshed==3.0.9
proto-plus==1.24.0
protobuf==4.25.3
psutil==6.0.0
pyarrow==15.0.0
pyasn1==0.6.0
pyasn1_modules==0.4.1
pycparser==2.21
pycryptodome==3.20.0
pydantic==2.6.3
pydantic_core==2.16.3
PyJWT==2.9.0
pymilvus==2.3.6
pymssql==2.3.0
python-dateutil==2.8.2
python-dotenv==1.0.1
python-jose==3.3.0
python-multipart==0.0.9
pytz==2024.1
PyYAML==6.0.1
regex==2023.12.25
requests==2.31.0
rsa==4.9
six==1.16.0
smart-open==6.4.0
sniffio==1.3.1
spacy==3.7.4
spacy-legacy==3.0.12
spacy-loggers==1.0.5
SQLAlchemy==2.0.27
srsly==2.4.8
starlette==0.36.3
tenacity==8.2.3
thinc==8.2.3
tiktoken==0.6.0
tqdm==4.66.2
typer==0.9.0
typing-inspect==0.9.0
typing_extensions==4.10.0
tzdata==2024.1
ujson==5.9.0
urllib3==2.2.1
uvicorn==0.29.0
uvloop==0.19.0
wasabi==1.1.2
watchfiles==0.21.0
weasel==0.3.4
websockets==12.0
yarl==1.9.4

User's image

any one please help me out.......!!!!

User's image

User's image

Azure SQL Database
Azure Container Registry
Azure Container Registry
An Azure service that provides a registry of Docker and Open Container Initiative images.
468 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,094 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 27,446 Reputation points
    2024-10-27T17:39:08.6633333+00:00

    The error message you’re encountering, which mentions that the database is "not currently available," often arises from transient connection issues or configuration problems within Azure App Service or SQL Database settings. First, ensure the SQL Database is indeed accessible by trying to connect directly from another tool like SQL Server Management Studio or Azure Data Studio. This can confirm if the issue is specific to your app or if there are broader connectivity issues with the database.

    Check your firewall and network configuration in Azure. Go to the SQL Database in the Azure portal and verify that its firewall rules allow the outbound IP address of your Azure App Service. If your SQL Database is within a Virtual Network (VNet), confirm that the App Service has been configured to access this VNet as needed.

    It's also important to confirm the accuracy of your connection string and authentication method. Review the connection string to ensure it’s configured correctly and that the authentication mode you’ve selected (such as Managed Identity, SQL Authentication, or Azure AD) aligns with your setup. If you’re using a managed identity, make sure this identity has been granted the necessary role, like db_datareader or db_datawriter, on the SQL Server. In SQL Server, add this identity and assign the required permissions to avoid authentication issues.

    Sometimes, transient deployment issues can cause connectivity errors. Stopping and restarting the App Service or redeploying the container can help reset the environment. If the issue persists, you might want to enable diagnostic logging for both the SQL Database and App Service in the Azure portal to gather more detailed error information, which can provide clues on any persistent configuration or connectivity issues.

    For more details on setting up firewall rules for SQL databases, check this Azure documentation. For guidance on using managed identities with SQL, refer to this guide.


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.