Rasshu
Rasshu

Reputation: 1799

UnknownHostException when connecting to Azure Cosmos DB using Cassandra

I followed the official instructions of Azure Portal. This is my

config.properties:

cassandra_host="demodemodemo.cassandra.cosmosdb.azure.com"
cassandra_username="demo"
cassandra_password="aHaplLoWhRlysBrtJWiOwB79TkqSU9PjKLu5wDeltLqys5NpR9vmtHCJrTF4ScdY69yNSWUvTUphax8RijydTA=="
cassandra_port=10350
ssl_keystore_file_path=
ssl_keystore_password=

Then it throws java.lang.IllegalArgumentException: Failed to add contact point and Caused by: java.net.UnknownHostException: "demodemodemo.cassandra.cosmosdb.azure.com" at this point:

[ CassandraUtils class, getSession() method ]

cluster = Cluster.builder()
                    .addContactPoint(cassandraHost)

Upvotes: 3

Views: 2478

Answers (2)

fascynacja
fascynacja

Reputation: 2826

I had similar problem. My corporate on prem environment is behind a proxy. Since I was using cassandra, I could not setup a http-proxy (it has its own protocol). The solution might be to use Azure Private Link. An example tutorial on how to do it is here: https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-configure-private-endpoints

Upvotes: 0

Nick Chapsas
Nick Chapsas

Reputation: 7200

You need to remove the double quotes from the settings.

If your credentials are correct, this should work.

cassandra_host=demodemodemo.cassandra.cosmosdb.azure.com
cassandra_username=demo
cassandra_password=aHaplLoWhRlysBrtJWiOwB79TkqSU9PjKLu5wDeltLqys5NpR9vmtHCJrTF4ScdY69yNSWUvTUphax8RijydTA==
cassandra_port=10350

Also by default the username is the same as the first part of the host so in your case demodemodemo except if you changed it.

Upvotes: 2

Related Questions