-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to skip SSL authentication when connecting to Emulator running in Linux Docker Container #2706
Comments
What is likely happening is the SDK is not able to connect to the emulator. Please take a look at this issue: #1551 |
This does not solve my issue. I already used the code mentioned in #1551. I can browse the cosmos db in the browser, however I can't connect via the C# client. Fun fact: It works when running the emulator as a Windows container, but not when running as a Linux container. I want to use the linux container. |
Can you share the actual error you are getting? The program cannot just hang, can you leave it running for some minutes? This might not be an SSL issue, but rather, the application not able to contact the endpoint, which has nothing to do with the SDK or SSL configuration. |
Well the endpoint is there, i can browse it via https://localhost:8081/_explorer/index.html and also via https://myip:8081/_explorer/index.html There is no error message, even though I let it run for multiple minutes. If i stop the linux emulator, switch to windows containers and run the windows emulator, it works w/o issues. |
The only thing I can think of is some issue on the Linux Emulator (which is still in preview?) If this was an issue on the SDK, it would repro on a real account and any of the emulators. Have you tried running the app outside of VS? Maybe VS is breaking on an exception and it feels like it's doing nothing? |
You're right, I also think now it might be an issue with the emulator, since the official page only describes how to use the linux emulator on a linux host but not on a windows host. I will raise an issue to the emulator team. However, it still is strange that theres no error coming, even if I run it outside of VS as you suggested. |
@davidguidali Was there any progress with the Linux emulator? |
Closing due to inactivity, please reopen if there is any new finding |
hi @ealsur I got exactly the same issue and behavior. I'm trying to connect to cosmosdb linux emulator(docker) from host (.net 6 app) suing SDK v3. No exceptions at all. Probably you are right and this is problems related to cosmosdb linux emulator since it's still in preview. |
Assuming you are also setting the |
@ealsur exactly. What I can see in debug that time to time my break point triggered here UPD: is it hard to use generated certificate(in linux container) for windows? For my case I should use it in CI with linux build agent as well. |
@davidguidali I am also struggling with this issue, but my setup is a bit different as I have Docker on Ubuntu on WSL2 and started the emulator according to the documentation link
One interesting thing is that the Third scenario is when I run the exact same app on Ubuntu/WSL2 - everything works and the application is creating the db and containers without any problems. So I think that confirms your assumptions, that Cosmos DB Emulator for Linux is limited to use only on that OS... |
I have the exact same problem. Emulator running in wsl (latest tag) and client 3.32.1. Client code is running on windows. My debug output is looping this:
Client code:
The awaited call to client.CreateDatabaseAsync never returns. There is no output in the emulators console, it just says:
Everything works fine making direct REST calls. |
@ealsur is there anyway to resolve this? |
Low and behold the solution has been available this whole time. But because there is no kind of reference documentation for the docker image (just a bunch of learn articles) no one knows wtf all the env variables are or what they do. Waste of a morning. |
@worldspawn I'm running on the same issue |
Those are testcontainers method. So it starts cosmos in Docker. If you are running as a process on your host machine you just need to set the same environment variable |
I was experiencing the same issue. I worked around the issue with this:
I noticed that what was causing the error was that the CosmosDB emulator was giving out endpoints of its own for reading and writing. Unfortunately, those endpoints are not accessible on the host machine as the IPs are on the private Docker network. By adding LimitToEndpoint = true, those inaccessible endpoints are ignored. I am guessing it is possible to start the CosmosDB emulator in a way to emit ports on the host.docker.internal IP, but this flag got me up and running. |
Hi there
I am developing a C# .NET Core app (on windows) and want to connect to the cosmos emulator running in a linux docker container on docker desktop for windows. I don't want to use SSL authentication so I try to make use of the most recent CosmosClient of Microsoft.Azure.Cosmos package. However, this doesn't seem to work.
Steps to reproduce:
On a windows machine, pull the most recent image of the cosmos emulator
docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
Start up a new emulator container
docker run -p 8081:8081 -p 10251:10251 -p 10252:10252 -p 10253:10253 -p 10254:10254 -m 3g --cpus=2.0 --name=test-linux-emulator -e AZURE_COSMOS_EMULATOR_PARTITION_COUNT=10 -e AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=true -it mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
Navigate to https://localhost:8081/_explorer/index.html and download the sample app for C# .NET Core.
Open the sample app in Visual Studio and update the Nuget package Microsoft.Azure.Cosmos to Version 3.20.1.
Open the class Program.cs and change the method GetStartedDemoAsync to skip SSL authentication:
Then hit F5 to run the program.
Expected result
The program runs successfully.
Actual result
The program hangs in this.CreateDatabaseAsync();, never returning and never creating a database.
PS: I posted this also on the emulator github project but I think here its the better place..
The text was updated successfully, but these errors were encountered: