<p>I have a nodeJS api which uses a mongoDb. I deploy the application in a kubernetes cluster. 
Here you can find the kubernetes yml files <a href="https://github.com/daumann/chronas-api/tree/azure/kuberneties" rel="nofollow noreferrer">https://github.com/daumann/chronas-api/tree/azure/kuberneties</a></p>

<p>Now I want to use the azure cosmosdb for mongodb instatt of an container. 
<a href="https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb-introduction" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb-introduction</a></p>

<p>Can someone help me how I can do that. 
It would be create to use only the yml files from kuberneties to do so.</p>

<p>Cheers</p>

<p>Assuming you already launched your cosmos-db through Azure, you will need to use the generated connection string that you can pass to your application as a secret (since it contains a password). The connection string is of the format:</p>

<pre><code>mongodb://username:password@host:port/[database]?ssl=true
</code></pre>

<p>To create a secret (assuming you paste your connection string into the <code>connstring.txt</code> file:</p>

<pre><code>kubectl create secret generic cosmos-db-secret --from-file=./connstring.txt
</code></pre>

<p>Then in your application's deployment definition add:</p>

<pre><code>env:
  - name: MONGO_HOST
    valueFrom:
      secretKeyRef:
        name: cosmos-db-secret
        key: connstring
</code></pre>
