You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/local-emulator.md
+32-52Lines changed: 32 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -414,23 +414,7 @@ To open the Data Explorer, navigate to the following URL in your browser. The em
414
414
415
415
https://<emulator endpoint provided in response>/_explorer/index.html
416
416
417
-
If you have a .NET client application running on a Linux docker container and if you are running Azure Cosmos emulator on a host machine, in this case you can’t connect to the Azure Cosmos account from the emulator. Because the app is not running on the host machine, the certificate registered on the Linux container that matches the emulator’s endpoint cannot be added.
418
-
419
-
As a workaround, you can disable the server’s SSL certificate validation from your client application by passing a `HttpClientHandler` instance as shown in the following .Net code sample. This workaround is only applicable if you are using the `Microsoft.Azure.DocumentDB` Nuget package, it isn't supported with the `Microsoft.Azure.Cosmos` Nuget package:
using (DocumentClient client = new DocumentClient(new Uri(strEndpoint), strKey, httpHandler))
428
-
{
429
-
RunDatabaseDemo(client).GetAwaiter().GetResult();
430
-
}
431
-
```
432
-
433
-
In addition to disabling the SSL certificate validation, it is important that you start the emulator with the `/allownetworkaccess` option and the emulator’s endpoint is accessible from the host IP address rather than `host.docker.internal` DNS.
417
+
If you have a .NET client application running on a Linux docker container and if you are running Azure Cosmos emulator on a host machine, please follow the below section for Linux to import the certificate into the Linux docker container.
434
418
435
419
## Running on Mac or Linux<a id="mac"></a>
436
420
@@ -442,48 +426,44 @@ Within the Windows VM run the command below and make note of the IPv4 address.
442
426
ipconfig.exe
443
427
```
444
428
445
-
Within your application you need to change the URI for the DocumentClient object to use the IPv4 address returned by `ipconfig.exe`. The next step is to work around the CA validation when constructing the DocumentClient object. For this you will need to provide an HttpClientHandler to the DocumentClient constructor, which has it's own implementation for ServerCertificateCustomValidationCallback.
429
+
Within your application you need to change the URI used as Endpoint to use the IPv4 address returned by `ipconfig.exe` instead of `localhost`.
446
430
447
-
Below is an example of what the code should look like.
431
+
The next step, from the within the Windows VM, launch the Cosmos emulator from the command line using the following options.
448
432
449
-
```csharp
450
-
using System;
451
-
using Microsoft.Azure.Documents;
452
-
using Microsoft.Azure.Documents.Client;
453
-
using System.Net.Http;
454
-
455
-
namespace emulator
456
-
{
457
-
class Program
458
-
{
459
-
static async void Main(string[] args)
460
-
{
461
-
string strEndpoint = "https://10.135.16.197:8081/"; //IPv4 address from ipconfig.exe
If you are working on Linux, .NET relays on OpenSSL to do the validation:
440
+
441
+
1. [Export the certificate in PFX format](./local-emulator-export-ssl-certificates.md#how-to-export-the-azure-cosmos-db-ssl-certificate) (PFX is available when choosing to export the private key).
442
+
2. Copy that PFX file into your Linux environment.
4. Copy the CRT file to the folder that contains custom certificates in your Linux distribution. Commonly on Debian distributions, it is located on `/usr/local/share/ca-certificates/`.
448
+
```bash
449
+
cp YourCTR.crt /usr/local/share/ca-certificates/
450
+
```
451
+
5. Update the CA certificates, which will update the `/etc/ssl/certs/` folder.
452
+
```bash
453
+
update-ca-certificates
485
454
```
486
455
456
+
If you are working on Mac:
457
+
458
+
1. [Export the certificate in PFX format](./local-emulator-export-ssl-certificates.md#how-to-export-the-azure-cosmos-db-ssl-certificate) (PFX is available when choosing to export the private key).
459
+
2. Copy that PFX file into your Mac environment.
460
+
3. Open the *Keychain Access* application and import the PFX file.
461
+
4. Open the list of Certificates and identify the one with the name `localhost`.
462
+
5. Open the context menu for that particular item, select*Get Item* and under *Trust*>*When using this certificate* option, select*Always Trust*.
463
+

464
+
465
+
After following these steps, your environment will trust the certificate used by the Emulator when connecting to the IP address exposes by `/AllowNetworkAccess`.
466
+
487
467
## Troubleshooting
488
468
489
469
Use the following tips to help troubleshoot issues you encounter with the Azure Cosmos Emulator:
0 commit comments