I have a .Net 5.0 API using ODP.NET that is deployed to Azure with a Docker image. It connects to an on-prem Oracle 12.c instance using a hybrid connection. This worked until yesterday, then it started throwing this exception. I cannot pin down any change that could be causing this and would be eternally grateful for pointers.
2021-02-12T23:59:48.562456333Z Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-12154: TNS:could not resolve the connect identifier specified
2021-02-12T23:59:48.562460133Z ---> OracleInternal.Network.NetworkException (0x00002F7A): ORA-12154: TNS:could not resolve the connect identifier specified
2021-02-12T23:59:48.562464033Z at OracleInternal.Network.AddressResolution..ctor(String TNSAlias, SqlNetOraConfig SNOConfig, Hashtable ObTnsHT, Hashtable ObLdpHT, String instanceName, ConnectionOption CO)
2021-02-12T23:59:48.562467834Z at OracleInternal.Network.OracleCommunication.Resolve(String tnsAlias, ConnectionOption& CO)
2021-02-12T23:59:48.562471734Z at OracleInternal.ConnectionPool.PoolManager`3.ResolveTnsAlias(ConnectionString cs, Object OC)
The app uses the OracleConnectionStringBuilder and EZ Connect syntax. I probably took the following from How to connect Oracle Database to Visual Studio C# project.
OracleConnectionStringBuilder sb = new OracleConnectionStringBuilder
{
DataSource = _configuration["Oracle_Host"],
UserID = _configuration["Oracle_User"],
Password = _configuration["Oracle_Password"]
};
The resulting connection string (taken from a local debug session) looks like this:
{USER ID=username;PASSWORD=apssword;DATA SOURCE=hostname:1521/sid}
There is no Oracle client and no tnsnames.ora on the server.
The server configuration settings are identical, and I have to assume that it ends up building the same connection string, although I have only verified the individual pieces, not the full connection string. The ADO build pipeline has not changed, the server configuration hasn't, either. There was a deployment but no code changes related to the database connection. A unit test was added.
Someone successfully installed SQL Plus on the blade and connected that way with the same settings, so network connectivity is there.
From the stack trace, it looks like somehow the EZ Connect syntax does not take on the server and it is trying resolve a TNS alias that is not there, but I have no idea why this could happen. Thanks!
User contributions licensed under CC BY-SA 3.0