oracledatabase-connectionodp.net-managed

ODP.NET and managed connections fail with ORA-12154


I thought the whole point of using ODP.Net Managed Connections, via Oracle.ManagedDataAccess.Core NuGet package, is that you don't need an Oracle client installed in the runtime environment. I find lots of posts about the

ORA-12154: TNS:could not resolve the connect identifier specified error

error but all discussions about potential fixes evolve around client configuration issues.

I doing exactly what is described in this article. The app connects fine when I run it locally from Visual Studio but when it is built and deployed by an Azure pipeline it cannot connect. Connectivity from the server is not the issue, and there are no tnsnames.ora and sqlnet.ora files, or TNS_ADMIN and ORA_HOME environment variables.

2021-02-15T18:04:40.867284043Z       Oracle connection string: (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<ip address>)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=<sid>)));User Id=<User>;Password=<Password>;
2021-02-15T18:04:40.871226968Z [41m[30mfail[39m[22m[49m: Microsoft.AspNetCore.Server.Kestrel[13]
2021-02-15T18:04:40.871246768Z       Connection id "0HM6HRG9F3OUG", Request id "0HM6HRG9F3OUG:00000004": An unhandled exception was thrown by the application.
2021-02-15T18:04:40.871252068Z       Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-12154: TNS:could not resolve the connect identifier specified
2021-02-15T18:04:40.871255568Z        ---> OracleInternal.Network.NetworkException (0x00002F7A): ORA-12154: TNS:could not resolve the connect identifier specified

I tried this EZ Connect string as well, with no success:

<user>/<password>@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=<ip address>)(Port=<port>))(CONNECT_DATA=(SID=<mysid>)))

What am I missing?

Update: The issue seems to be caused by an underlying issue with the Azure Hybrid Connection manager and not the Oracle connection. Looking into a VPN connection now. Hold your suggestions for trying different connection string formats for now.


Solution

  • This error was caused by an incorrectly configured Azure Hybrid Connection between the app service and our client's on-prem legacy Oracle database. The "could not resolve" part of the error message is actually spot-on and indicates an underlying DNS error.