Hi @Oury Ba-MSFT any updates?
May be there is standard approach how to check connection to PostgreSQL database from APP Service?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Newly created PostgreSQL Flexible server is not available:
Have several environments:
-DEV, PostgreSQL Flexible server version - 14.8, Connectivity method - Public Acess
-QA, PostgreSQL Flexible server version - 14.8, Connectivity method - Public Acess
"Allow public access from any Azure service within Azure to this server" option is enabled on both environments.
Connection string is located as secret in Azure Key Vault, separately for DEV and QA.
Issue is that App service (API solution on .net core) cant reach PostreSQL Flexible server on QA environment.
Information from API Log Stream ->
2023-09-07T08:06:57.244808610Z Unhandled exception. System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000005, 0xFFFDFFFF): Name or service not known
2023-09-07T08:06:57.244881509Z at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, ValueStopwatch stopwatch)
2023-09-07T08:06:57.244890709Z at System.Net.Dns.GetHostAddresses(String hostNameOrAddress, AddressFamily family)
2023-09-07T08:06:57.244896209Z at Npgsql.Internal.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
2023-09-07T08:06:57.244901409Z at Npgsql.Internal.NpgsqlConnector.RawOpen(SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
2023-09-07T08:06:57.244906809Z at Npgsql.Internal.NpgsqlConnector.<Open>g__OpenCore|203_1(NpgsqlConnector conn, SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
2023-09-07T08:06:57.244912809Z at Npgsql.Internal.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
2023-09-07T08:06:57.244917909Z at Npgsql.UnpooledDataSource.Get(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
2023-09-07T08:06:57.244923109Z at Npgsql.NpgsqlConnection.<Open>g__OpenAsync|45_0(Boolean async, CancellationToken cancellationToken)
2023-09-07T08:06:57.244928409Z at Npgsql.NpgsqlConnection.Open()
2023-09-07T08:06:57.244933209Z at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)
2023-09-07T08:06:57.244938209Z at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternal(Boolean errorsExpected)
2023-09-07T08:06:57.244943109Z at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)
2023-09-07T08:06:57.244948009Z at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlDatabaseCreator.Exists(Boolean async, CancellationToken cancellationToken)
2023-09-07T08:06:57.244953009Z at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlDatabaseCreator.Exists(Boolean async, CancellationToken cancellationToken)
2023-09-07T08:06:57.244958009Z at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlDatabaseCreator.Exists()
2023-09-07T08:06:57.244962909Z at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists()
2023-09-07T08:06:57.244967809Z at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
2023-09-07T08:06:57.244974208Z at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate(DatabaseFacade databaseFacade)
If any other information is required just let me know.
Pretty interesting issue I faced.
What could be the reason and possible solution?
Thanks
Hi @Oury Ba-MSFT any updates?
May be there is standard approach how to check connection to PostgreSQL database from APP Service?
Hi Oleg Katiuk •
To answer your questions- how to check connection to PostgreSQL database from APP Service?
Hopefully, the document and blog link below will be helpful
Connection handling best practice with PostgreSQL - Microsoft Community Hub
Thank you!