Skip to content

Commit 37df2a5

Browse files
committed
Add certificate instructions for Windows
1 parent 1d815c9 commit 37df2a5

File tree

1 file changed

+76
-9
lines changed

1 file changed

+76
-9
lines changed

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

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,24 @@ The Docker container variant of the emulator doesn't support the API for Table.
245245
| **`AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE` *(Optional)*** | *Enable data persistence between emulator runs.* |
246246
| **`AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE` *(Optional)*** | *Override the emulator's default IP address.* |
247247
248+
For Linux systems, use:
249+
248250
```bash
249251
docker run \
250252
--publish 8081:8081 \
251253
--publish 10250-10255:10250-10255 \
254+
--name linux-emulator \
252255
--detach \
253256
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest
254257
```
255258
259+
For Windows systems, use:
260+
256261
```powershell
257262
$parameters = @(
258263
"--publish", "8081:8081"
259264
"--publish", "10250-10255:10250-10255"
265+
"--name", "windows-emulator"
260266
"--detach"
261267
)
262268
docker run @parameters mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest
@@ -274,6 +280,7 @@ The Docker container variant of the emulator doesn't support the API for Table.
274280
$parameters = @(
275281
"--publish", "8081:8081"
276282
"--publish", "10250-10255:10250-10255"
283+
"--name", "windows-emulator"
277284
"--detach"
278285
)
279286
docker run @parameters mcr.microsoft.com/cosmosdb/windows/azure-cosmos-emulator
@@ -319,20 +326,26 @@ The Docker container variant of the emulator doesn't support the API for Table.
319326
| **`AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE` *(Optional)*** | *Enable data persistence between emulator runs.* |
320327
| **`AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE` *(Optional)*** | *Override the emulator's default IP address.* |
321328
329+
For Linux systems, use:
330+
322331
```bash
323332
docker run \
324333
--publish 8081:8081 \
325334
--publish 10250:10250 \
326335
--env AZURE_COSMOS_EMULATOR_ENABLE_MONGODB_ENDPOINT=4.0 \
336+
--name linux-emulator \
327337
--detach \
328338
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:mongodb
329339
```
330340
341+
For Windows systems, use:
342+
331343
```powershell
332344
$parameters = @(
333345
"--publish", "8081:8081"
334346
"--publish", "10250:10250"
335347
"--env", "AZURE_COSMOS_EMULATOR_ENABLE_MONGODB_ENDPOINT=4.0"
348+
"--name", "windows-emulator"
336349
"--detach"
337350
)
338351
docker run @parameters mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:mongodb
@@ -388,8 +401,20 @@ The Windows local installation of the emulator automatically imports the TLS/SSL
388401

389402
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.
390403

404+
For Linux systems, use:
405+
391406
```bash
392-
curl -k https://localhost:8081/_explorer/emulator.pem > ~/emulatorcert.crt
407+
curl --insecure https://localhost:8081/_explorer/emulator.pem > ~/emulatorcert.crt
408+
```
409+
410+
```powershell
411+
$parameters = @{
412+
Uri = 'https://localhost:8081/_explorer/emulator.pem'
413+
Method = 'GET'
414+
OutFile = 'emulatorcert.crt'
415+
SkipCertificateCheck = $True
416+
}
417+
Invoke-WebRequest @parameters
393418
```
394419

395420
### [Docker (Windows container)](#tab/docker-windows)
@@ -404,40 +429,82 @@ The Windows local installation of the emulator automatically imports the TLS/SSL
404429
405430
::: zone pivot="api-nosql"
406431
407-
### [Docker (Linux container) / Docker (Windows container)](#tab/docker-linux+docker-windows)
432+
### [Docker (Linux container)](#tab/docker-linux)
433+
434+
The certificate for the emulator is available at the path `/_explorer/emulator.pem` on the running container.
408435
409-
The certificate for the emulator is available at the path `_explorer/emulator.pem` on the running container.
436+
1. Download the certificate from the running container to your local machine.
410437
411-
1. Use `curl` to download the certificate from the running container to your local machine.
438+
For Linux systems, use:
412439
413440
```bash
414-
curl -k https://localhost:8081/_explorer/emulator.pem > ~/emulatorcert.crt
441+
curl --insecure https://localhost:8081/_explorer/emulator.pem > ~/emulatorcert.crt
442+
```
443+
444+
For Windows systems, use:
445+
446+
```powershell
447+
$parameters = @{
448+
Uri = 'https://localhost:8081/_explorer/emulator.pem'
449+
Method = 'GET'
450+
OutFile = 'emulatorcert.crt'
451+
SkipCertificateCheck = $True
452+
}
453+
Invoke-WebRequest @parameters
415454
```
416455
417456
> [!NOTE]
418457
> You may need to change the host (or IP address) and port number if you have previously modified those values.
419458
420459
1. Install the certificate according to the process typically used for your operating system. For example, in Linux you would copy the certificate to the `/usr/local/share/ca-certificates/` path.
421460
461+
For Linux systems, use:
462+
422463
```bash
423464
cp ~/emulatorcert.crt /usr/local/share/ca-certificates/
424465
```
425466
426-
1. Regenerate the certificate bundle by using the appropriate command for your Linux distribution.
467+
For Windows systems, use:
427468
428-
For **Debian-based** systems (for example, Ubuntu), use:
469+
```powershell
470+
$parameters = @{
471+
FilePath = 'emulatorcert.crt'
472+
CertStoreLocation = 'Cert:\CurrentUser\Root'
473+
}
474+
Import-Certificate @parameters
475+
```
476+
477+
1. For linux systems, regenerate the certificate bundle by using the appropriate command for your Linux distribution.
478+
479+
For **Debian-based** Linux systems (for example, Ubuntu), use:
429480
430481
```bash
431482
sudo update-ca-certificates
432483
```
433484
434-
For **Red Hat-based** systems (for example, CentOS, Fedora), use:
485+
For **Red Hat-based** Linux systems (for example, CentOS, Fedora), use:
435486
436487
```bash
437488
sudo update-ca-trust
438489
```
439490
440-
For more detailed instructions, consult the documentation specific to your Linux distribution.
491+
For more detailed instructions, consult the documentation specific to your operating system.
492+
493+
### [Docker (Windows container)](#tab/docker-windows)
494+
495+
The certificate for the emulator is available at the folder `C:\CosmosDB.Emulator\bind-mount` on the running container. The folder also contains a script to automatically install the certificate.
496+
497+
1. Use `docker cp` to copy the entire folder to your local machine.
498+
499+
```powershell
500+
docker cp windows-emulator:C:\CosmosDB.Emulator\bind-mount .
501+
```
502+
503+
1. Run the *importcert.ps1* script in the folder.
504+
505+
```powershell
506+
.\bind-mount\importcert.ps1
507+
```
441508
442509
### [Windows (local)](#tab/windows)
443510

0 commit comments

Comments
 (0)