question

Rimar-1755 avatar image
0 Votes"
Rimar-1755 asked ·

Error migrating Django database to Postgres by de SSH web

By migrating the database of a Django app, I can enter the virtual environment and install the dependencies. But when I try to migrate the database, the following messages are displayed: 'FATAL: Password authentication failed for user "root"' and 'FATAL: SSL connection is required. Please specify SSL options and retry.'

Could someone help me? Does anyone know what may be happening?

azure-webappsazure-webapps-sshazure-webapps-migration
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Rimar-1755, what commands did you use to migrate? Are you access SSL through the Azure portal or a different tool? Are you following the steps outlined in https://docs.microsoft.com/en-us/azure/app-service/containers/tutorial-python-postgresql-app?

0 Votes 0 ·
Rimar-1755 avatar image
0 Votes"
Rimar-1755 answered ·

Hi @ryanchill . Thank you for your answer. Yes, I'm folowing the "Deploy a Django web app with PostgreSQL in Azure App Service" tutorial. I'm not using SSL. I'm using SSH through the Web SSH service as shown at the "Run Django database migrations" topic. I have used the Django command "python manage.py migrate". The command "python manage.py createsuperuser" didn't work also and generate the same error message. The previous commands "activate (the virtual environment)" and "pip install -r requirements.txt" (for the dependencies) runs ok without problems.
I'm suspecting for a problem with my login: I was already loged at Azure when I opened the Web SSH and it didn't ask me for a login. Ok, I assumed that I was already loged in and the two first commands runs ok. I will try once more time and send you the errors messages.
...
File "/opt/python/3.7.7/lib/python3.7/site-packages/psycopg2/init.py", line 126, in connect
conn = connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
FATAL: SSL connection is required. Please specify SSL options and retry.
...
File "/opt/python/3.7.7/lib/python3.7/site-packages/psycopg2/
init_.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
FATAL: SSL connection is required. Please specify SSL options and retry.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Grmacjon-MSFT avatar image
0 Votes"
Grmacjon-MSFT answered ·

Hi @Rimar-1755,

We apologize for the frustration this issue might have caused. from the error message, you posted "FATAL: SSL connection is required. Please specify SSL options and retry." it means you don't have SSL enabled.

Based on this doc " Azure Database for PostgreSQL prefers connecting your client applications to the PostgreSQL service using Transport Layer Security (TLS), previously known as Secure Sockets Layer (SSL). Enforcing TLS connections between your database server and your client applications helps protect against "man-in-the-middle" attacks by encrypting the data stream between the server and your application. By default, the PostgreSQL database service is configured to require TLS connection. You can choose to disable requiring TLS if your client application does not support TLS connectivity."

You can optionally disable enforcing TLS connectivity. Microsoft Azure recommends to always enable Enforce SSL connection setting for enhanced security. Please follow the steps shared here Configure TLS connectivity in Azure Database for PostgreSQL - Single Server to learn how to achieve this. You can disable requiring SSL connections from either the portal or using CLI. You can also see this related Stack Overflow thread for more details.


Hope that helps. Let us know if you have further questions.

-Grace



·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Rimar-1755 avatar image
0 Votes"
Rimar-1755 answered ·

Thank you @Grmacjon-MSFT ,

We are used to some frustration in our work. It's ok. I'm just doing the tutorial "Deploy a Django web app with PostgreSQL in Azure App Service" where I think that should have some advice about this issue. Whatever, I still have some doubts:

  1. Was this issue caused by the use of the Web/HTTP SSH interface?

  2. Must I disable requiring SSL connections every time I migrate the DB?

  3. Is there some Windows 10 or VS Code plugin alternative to Web SSH?

Thank you for your help.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Rimar-1755 avatar image
0 Votes"
Rimar-1755 answered ·

Hi @Grmacjon-MSFT ,


I have tryed disable the requiring SSL connections from the portal, confirmed the new SSL status, opened the WebSSH, activated the virtual env and execute the command "python manage.py migrate" and the same error was risen. What would have happened?


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Rimar-1755 avatar image
0 Votes"
Rimar-1755 answered ·

The error "FATAL: SSL connection is required. Please specify SSL options and retry." is still shown when I try to run the command "python manage.py migrate", even after I disable the "requiring SSL connections" option. Please, Is there something else to do, to solve this issue?

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for the update @Rimar-1755. It looks like this issue requires deeper investigation. Can you please send us an email
at azcommunity[at]microsoft[dot]com, subject: ATTN [Grace] and include the link to this thread along with your subscription ID

-Grace

0 Votes 0 ·
Rimar-1755 avatar image
0 Votes"
Rimar-1755 answered ·

Thank you very much for the help @Grmacjon-MSFT. I have found the cause of the issue. It was caused by an error in filling in the environment variables. The error message confused me by assigning the cause to a SSL error. These messages should be reviewed. I apreciate your help. Best regards, take care and good luck for you.

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Rimar-1755,

So glad to hear you were able to resolve your problem. Thanks for sharing what caused the error. I am sure others will find it helpful as well.

I will share this feedback with our engineering team. Which environment variables helped fix your issue?

0 Votes 0 ·
Rimar-1755 avatar image
0 Votes"
Rimar-1755 answered ·

Hi @Grmacjon-MSFT ,
The wrong environment variable was the "resource-group". My mistake was to put the application's resource group in place of the database resource group. It's a trivial error but the error message confused me.
It's all right now. Thank you once more time.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.