Skip to content

Commit ea32928

Browse files
committed
Update Azure Cosmos DB Emulator instructions for python
1 parent d5ad4fc commit ea32928

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

articles/cosmos-db/how-to-develop-emulator.md

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,9 @@ The Docker (Windows) container image doesn't support the API for MongoDB.
351351
352352
::: zone-end
353353
354-
## Export the emulator's TLS/SSL certificate
354+
## Import the emulator's TLS/SSL certificate
355355

356-
Export the certificate for the emulator to use the emulator with your preferred developer SDK without disable TLS/SSL on the client.
356+
Import the emulator's TLS/SSL certificate to use the emulator with your preferred developer SDK without disabling TLS/SSL on the client.
357357
358358
::: zone pivot="api-apache-cassandra,api-apache-gremlin,api-table"
359359
@@ -371,7 +371,7 @@ The Windows local installation of the emulator automatically imports the TLS/SSL
371371

372372
### [Docker (Linux container)](#tab/docker-linux)
373373

374-
The certificate for the emulator is available in the `_explorer/emulator.pem` path on the running container. Use `curl` to download the certificate from the running container to your local machine.
374+
The certificate for the emulator is available at the path `_explorer/emulator.pem` on the running container. Use `curl` to download the certificate from the running container to your local machine.
375375

376376
```bash
377377
curl -k https://localhost:8081/_explorer/emulator.pem > ~/emulatorcert.crt
@@ -391,7 +391,7 @@ The Windows local installation of the emulator automatically imports the TLS/SSL
391391
392392
### [Docker (Linux container) / Docker (Windows container)](#tab/docker-linux+docker-windows)
393393
394-
The certificate for the emulator is available in the `_explorer/emulator.pem` path on the running container.
394+
The certificate for the emulator is available at the path `_explorer/emulator.pem` on the running container.
395395
396396
1. Use `curl` to download the certificate from the running container to your local machine.
397397
@@ -418,7 +418,7 @@ The Windows local installation of the emulator automatically imports the TLS/SSL
418418
419419
## Connect to the emulator from the SDK
420420
421-
Each SDK includes a client class typically used to connect the SDK to your Azure Cosmos DB account. Using the [emulator's credentials](emulator.md#authentication), you can connect the SDK to the emulator instance instead.
421+
Each SDK includes a client class typically used to connect the SDK to your Azure Cosmos DB account. By using the [emulator's credentials](emulator.md#authentication), you can connect the SDK to the emulator instance instead.
422422

423423
::: zone pivot="api-nosql"
424424

@@ -536,6 +536,40 @@ Use the [Azure Cosmos DB API for NoSQL Python SDK](nosql/quickstart-python.md) t
536536
> ```
537537
>
538538
539+
If you are still facing SSL errors, it is possible that Python is retrieving the certificates from a different certificate store. To determine the path where Python is looking for the certificates, follow these steps:
540+
>[!IMPORTANT]
541+
>If you are using a Python **virtual environment** (venv) ensure it is **activated** before running the commands!
542+
1. Open a terminal
543+
1. Start the Python interpreter by typing python or python3, depending on your Python version.
544+
1. In the Python interpreter, run the following commands:
545+
```python
546+
from requests.utils import DEFAULT_CA_BUNDLE_PATH
547+
print(DEFAULT_CA_BUNDLE_PATH)
548+
```
549+
550+
**Inside a virtual environment**, the path may be (at least in Ubuntu):
551+
```bash
552+
path/to/venv/lib/pythonX.XX/site-packages/certifi/cacert.pem
553+
```
554+
555+
**Outside of a virtual environment**, the path may be (at least in Ubuntu):
556+
```bash
557+
/etc/ssl/certs/ca-certificates.crt
558+
```
559+
560+
1. Once you have identified the DEFAULT_CA_BUNDLE_PATH, open a **new terminal** and run the following commands to append the emulator certificate to the certificate bundle:
561+
> [!IMPORTANT]
562+
> If DEFAULT_CA_BUNDLE_PATH variable points to a system directory, you might encounter a **"Permission denied"** error. In this case, you will need to run the commands with elevated privileges (as root).
563+
>
564+
```bash
565+
# Add a new line to the certificate bundle
566+
echo >> /path/to/ca_bundle
567+
```
568+
```bash
569+
# Append the emulator certificate to the certificate bundle
570+
cat /path/to/emulatorcert.crt >> /path/to/ca_bundle
571+
```
572+
539573
### [JavaScript / Node.js](#tab/javascript+nodejs)
540574
541575
Use the [Azure Cosmos DB API for NoSQL Node.js SDK](nosql/quickstart-nodejs.md) to connect to the emulator from a Node.js/JavaScript application.

0 commit comments

Comments
 (0)