Oracle fails with `ORA-12154: TNS:could not resolve` if not overriden
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
```csharp
var oracle = builder
.AddOracle("oracle")
.WithImage("database/free", "23.8.0.0")
.WithImageRegistry("container-registry.oracle.com")
.WithLifetime(builder.GetLifetime());
```
throws Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-12154: TNS:could not resolve the connect identifier specified
, when hacked using
```csharp
var oracle = builder
.AddOracle("oracle")
.WithImage("database/free", "23.8.0.0")
.WithImageRegistry("container-registry.oracle.com")
.WithLifetime(builder.GetLifetime());
var oracleDb = oracle.AddDatabase("billing-oracle", databaseName: "FREE");
// Fix: Oracle connection string needs full TNS descriptor with SERVICE_NAME
// ODP.NET requires DESCRIPTION format because EZCONNECT is not enabled by default
// Format: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=port))(CONNECT_DATA=(SERVICE_NAME=FREE)))
var oracleConnStr = builder.AddConnectionString(
"oracledb-fixed",
ReferenceExpression.Create(
$"user id=system;password={oracle.Resource.PasswordParameter};"
+ $"data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST={oracle.Resource.PrimaryEndpoint.Property(EndpointProperty.Host)})(PORT={oracle.Resource.PrimaryEndpoint.Property(EndpointProperty.Port)}))(CONNECT_DATA=(SERVICE_NAME=FREE)))"
)
);
database = oracleConnStr;
```
referencing `oracleConnStr` gives correct results
### Expected Behavior
```csharp
var oracle = builder
.AddOracle("oracle")
.WithImage("database/free", "23.8.0.0")
.WithImageRegistry("container-registry.oracle.com")
.WithLifetime(builder.GetLifetime());
```
should work without hacks
### Steps To Reproduce
Have Oracle Client 19.0.0 installed along with Podman CLI.
### Exceptions (if any)
Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-12154: TNS:could not resolve the connect identifier specified
### Aspire doctor output
_No response_
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.