Azure / service-fabric-mesh-preview

Service Fabric Mesh is the Service Fabric's serverless offering to enable developers to deploy containerized applications without managing infrastructure. Service Fabric Mesh , aka project “SeaBreeze” is currently available in private preview. This repository will be used for tracking bugs/feature requests as GitHub issues and for maintaining the latest documentation.
MIT License
82 stars 12 forks source link

No network access from console application #302

Open aloneguid opened 5 years ago

aloneguid commented 5 years ago

The latest preview SDK 3.3.617 has some issues with code trying to get access to external network. For instance simple code:

string text = new WebClient().DownloadString("https://microsoft.com");

will fail from console application when running on a local cluster ("no such host is known"). The funny thing is it will succeed when running in API app, therefore the issue is not with docker networking as I thought before. Does anyone have any pointers?

BigMorty commented 5 years ago

@aloneguid - Try adding an EXPOSE statement to the first section of your Dockerfile.

aloneguid commented 5 years ago

Expose works, I posted this as workaround on another thread already but that seems like a bug to me?

BigMorty commented 5 years ago

Glad that worked, sorry I did not see the other thread, which one was it? The SF team is still looking into the root cause of this.

aloneguid commented 5 years ago

I've posted this on Azure advisors originally) found that the only difference between Web and console is expose command, nothing else is happening different, procmon says they fire up identicaly.

BigMorty commented 5 years ago

Gotcha, thanks.

jsmithtx commented 5 years ago

@aloneguid You said the EXPOSE statement worked for you. Could you share your dockerfile or at least the portion that worked? I am trying to get my console Mesh application to talk to my local Cosmos emulator and a local SQL server instance and I can't get it to succeed. Thanks.

aloneguid commented 5 years ago

@jiffypopjr the dockerfile should start like this:

FROM microsoft/dotnet:2.1-runtime AS base
WORKDIR /app
EXPOSE 80 <--- extra line

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
...
jsmithtx commented 5 years ago

I've exposed both ports, in an attempt to get to the local Cosmos emulator, but this doesn't seem to work. How would I, in a 'worker' Mesh node, get to a local Cosmos instance running on the host system from within the container? I've tried the host name (with also launching Mesh with the -UseComputerName arg), and tried the various IP address that docker inspect provides, but with no success.

The host port for Cosmos is 8081. Thanks!

EXPOSE 80 EXPOSE 8081

BigMorty commented 5 years ago

@sridmad - Any ideas?

aloneguid commented 5 years ago

@jiffypopjr normally you would compose host name as "servicename.applicationname" -this will resolve both in local cluster and Azure well.

Are you trying to access emulator running in a container belonging to the same application, or your host machine?

sridmad commented 5 years ago

Connectivity issue for console project or any image without EXPOSE statement is addressed in the runtime with 3.3.622 SDK.

https://docs.microsoft.com/en-us/azure/service-fabric-mesh/service-fabric-mesh-howto-setup-developer-environment-sdk

jsmithtx commented 5 years ago

@aloneguid I was trying to access the Cosmos emulator that is running in the host machine (https:/localhost:8081). After digging quite a bit, I found that I could use the servicefabric_nat Gateway IP address as the host address and at least was able to access my host instance of Seq logging; however, because the Cosmos emulator uses SSL, the container was unable to establish a trust relationship with the host. Thus far I've attempted to register the Cosmos host local certificate in the container as a CA, Root, and My with no success (RUN certutil -addstore "Root" ./DocumentDBEmulatorCertificate.cer). I may try running the cosmos emulator as a container itself and see if I can do container-to-container communication next. If that fails, I'll try using tcp for communication

sridmad commented 5 years ago

@jiffypopjr , I have opened a different issue for connectivity to ports on machine IP.

julipur commented 5 years ago

@jiffypopjr Hi Josh, wondering if you got this working with Cosmos running in docker (either on the same container as the mesh application or via container to container communication)