<p>Using the <strong>Datastax C# Driver</strong> I'm trying to connect to Cassandra which was deployed to Azure Kubernetes Services using a Bitnami helm chart.</p>
<pre><code>var cluster = Cluster.Builder()
   .AddContactPoint(&quot;127.0.0.0&quot;) // example IP
   .WithCredentials(&quot;cassie&quot;, &quot;some-pass&quot;)
   .Build();
</code></pre>
<p>When trying this locally I use <code>kubectl port-forward</code>, but when I'm uploading my service to Kubernetes I want to use service name. Many applications shown to me by colleagues use just that. When I add the link that helm chart gives to me after I install it</p>
<blockquote>
<p>Cassandra can be accessed through the following URLs from within the cluster:</p>
<ul>
<li>CQL: service-name.some-namespace.svc.cluster.local:9042</li>
</ul>
</blockquote>
<p>I'm unable to connect, I'm getting a <strong>Cassandra.NoHostAvailableException</strong> and I have to use an IP.</p>
<p>How to solve this problem. The IP changes every time I redeploy.
How can I use the name instead of the IP?</p>

Maurice Klimek
<p>Apparently, providing the DNS with format &quot;DNS:PORT&quot; as a parameter for AddContactPoint was not working. Using the method WithPort did the trick.</p>
<pre><code>var cluster = Cluster.Builder()
   .WithPort(PORT)
   .AddContactPoint(&quot;dns&quot;)
   .WithCredentials(&quot;cassie&quot;, &quot;some-pass&quot;)
   .Build();
</code></pre>
