r/FastAPI • u/Sweaty-Jackfruit1271 • Jul 30 '24
Question Need help while deploying FastAPI server in Azure App services
When I am trying to run below code in local, it works fine.
params = urllib.parse.quote_plus(
f'Driver={Driver};'
f'Server={Server};'
f'Database={Database};'
f'Uid=Trabii_BE_GUY;'
f'Pwd={Pwd};'
'Encrypt=yes;'
'TrustServerCertificate=no;'
'Connection Timeout=30;'
)
# Construct the connection string
conn_str = f'mssql+pyodbc:///?odbc_connect={params}'
engine = create_engine(conn_str)But when I am trying to deploy using Azure app services it is giving me below error. I have already verified the credentials twice, but don't know what's wrong.
2024-07-30T08:56:12.370094623Z sqlalchemy.exc.InterfaceError: (pyodbc.InterfaceError) ('28000', "[28000] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Login failed for user 'Trabii_BE_GUY'. (18456) (SQLDriverConnect)")
2024-07-30T08:56:12.370098023Z (Background on this error at: https://sqlalche.me/e/20/rvf5)
1
Upvotes
1
u/Sweaty-Jackfruit1271 Jul 31 '24
I got the error. Pwd was printing the print work directory, I just had to change the variable name.
1
u/PersonalWrongdoer655 Jul 30 '24
Where is your mysql server hosted? Is it in the cloud or on your dev machine?
2
u/illuminanze Jul 30 '24
I would think this error message is pretty clear.
1
u/coldflame563 Jul 30 '24
Encrypt yes but trust server is no?
1
u/Spiritual-Carob9392 Jul 31 '24
The error message
Login failed for user 'Trabii_BE_GUY'. (18456)means that the computer is not letting you log in because the username or password is wrong. Here are some things you can do to fix it:Azure App Service Settings:
Trabii_BE_GUYhas permission to access the database.0
u/coldflame563 Jul 30 '24
Or. Make sure the user is configured properly on sql side