ODP.NET and managed connections fail with ORA-12154

1

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.

oracle
database-connection
odp.net-managed
asked on Stack Overflow Feb 15, 2021 by cdonner • edited Feb 17, 2021 by cdonner

1 Answer

0

We see what is in the output, but need to see how you actually specified the connect string in the calling application. ora-12154 is one of the most common connection issues and is written about all over the internet. What did you discover when you googled it?

It says that you specified a tns connect string that could not be located in the client's tnsnames.ora file. Since I don't know the contents of your client's tnsnames, and I don't know what you actually specified, I can't say more at this point.

However, as noted, this error is written about in just about every oracle blog and online resource on the internet. My favorite is here: https://edstevensdba.wordpress.com/2018/09/19/troubleshooting-ora-12154/

Also . . . oracle:cdb$ oerr ora 12154 12154, 00000, "TNS:could not resolve the connect identifier specified" // *Cause: A connection to a database or other service was requested using // a connect identifier, and the connect identifier specified could not // be resolved into a connect descriptor using one of the naming methods // configured. For example, if the type of connect identifier used was a // net service name then the net service name could not be found in a // naming method repository, or the repository could not be // located or reached. // *Action: // - If you are using local naming (TNSNAMES.ORA file): // - Make sure that "TNSNAMES" is listed as one of the values of the // NAMES.DIRECTORY_PATH parameter in the Oracle Net profile // (SQLNET.ORA) // - Verify that a TNSNAMES.ORA file exists and is in the proper // directory and is accessible. // - Check that the net service name used as the connect identifier // exists in the TNSNAMES.ORA file. // - Make sure there are no syntax errors anywhere in the TNSNAMES.ORA // file. Look for unmatched parentheses or stray characters. Errors // in a TNSNAMES.ORA file may make it unusable. // - If you are using directory naming: // - Verify that "LDAP" is listed as one of the values of the // NAMES.DIRETORY_PATH parameter in the Oracle Net profile // (SQLNET.ORA). // - Verify that the LDAP directory server is up and that it is // accessible. // - Verify that the net service name or database name used as the // connect identifier is configured in the directory. // - Verify that the default context being used is correct by // specifying a fully qualified net service name or a full LDAP DN // as the connect identifier // - If you are using easy connect naming: // - Verify that "EZCONNECT" is listed as one of the values of the // NAMES.DIRETORY_PATH parameter in the Oracle Net profile // (SQLNET.ORA). // - Make sure the host, port and service name specified // are correct. // - Try enclosing the connect identifier in quote marks. // // See the Oracle Net Services Administrators Guide or the Oracle // operating system specific guide for more information on naming.

answered on Stack Overflow Feb 15, 2021 by EdStevens • edited Feb 15, 2021 by EdStevens

User contributions licensed under CC BY-SA 3.0