Closed rrr-michael-aquilina closed 1 year ago
Hello @rrr-michael-aquilina I did that, and all works fine on my side.
FROM mcr.microsoft.com/dotnet/sdk:3.1 as build
WORKDIR /source
COPY AzureEventGridSimulator/src/AzureEventGridSimulator/*.csproj . RUN dotnet restore
COPY AzureEventGridSimulator/src/AzureEventGridSimulator .
RUN dotnet publish -c release -o /app
FROM mcr.microsoft.com/dotnet/aspnet:3.1 WORKDIR /app COPY --from=build /app . COPY YOUR_CERT.com.pfx . COPY appsettings.json .
USER ContainerAdministrator ENV ASPNETCORE_KestrelCertificatesDefaultPassword="CERT_PASSWORD" ENV ASPNETCORE_KestrelCertificatesDefaultPath="C:\app\YOUR_CERT.com.pfx" ENV ASPNETCORE_ENVIRONMENT=Development
ENTRYPOINT ["AzureEventGridSimulator.exe"]
3. create example.appsettings.json and add your settings
4. build your image:
`docker build -t eventgrid_image_name_tag .`
5. run container, you can specify the configuration file, you have to map you config file. ${PWD} - your curretn folder. C:\temp\ - folder inside the container:
docker run -dit --rm -v ${PWD}:C:\temp\ --name eventgrid-dev eventgrid_image_name_tag --entrypoint AzureEventGridSimulator.exe --ConfigFile=C:\temp\appsettings.json
Thanks @AndreyBespamyatnov,
I'm using the image from docker hub.
This is the snippet of my docker compose which is pretty much untouched from the example.
image: pmcilreavy/azureeventgridsimulator
container_name: azureeventgridsimulator-dev
ports:
# add a port mapping for each topic in the settings file
- "60101:60101"
volumes:
# map a local folder './docker' to a read-only folder '/aegs' in the container
# this allows us to access files (e.g. settings or certificates) from within the container
- .:/workspace:cached
#entrypoint: ["sh", "/workspace/infra/playpen/functions/wait-for-and-trust-eventgrid.sh"]
environment:
- ASPNETCORE_ENVIRONMENT=Development
# specify cert details (note: can be generated like so: dotnet dev-certs https --export-path ./docker/azureEventGridSimulator.pfx --password Y0urSup3rCrypt1cPa55w0rd!`
- ASPNETCORE_Kestrel__Certificates__Default__Path=/usr/local/share/ca-certificates/azureEventGridSimulator.pfx
- ASPNETCORE_Kestrel__Certificates__Default__Password=Y0urSup3rCrypt1cPa55w0rd!
# example of how to configure a topic via environment variables
- AEGS_Topics__0__name=ExampleTopic
- AEGS_Topics__0__port=60101
- AEGS_Topics__0__key=TheLocal+DevelopmentKey=
# add an Azure Function subscriber running on localhost (host.docker.internal)
- AEGS_Topics__0__subscribers__1__name=AzureFunctionSubscription
- AEGS_Topics__0__subscribers__1__endpoint=http://host.docker.internal:7071/runtime/webhooks/EventGrid?functionName=Publish_Device_Event
- AEGS_Topics__0__subscribers__1__disableValidation=false
# logging configuration
- AEGS_Serilog__MinimumLevel__Default=Verbose
# you could also define topics/subscribers via via a configfile
# - ConfigFile=/aegs/appsettings.docker.json
When I start the container and my function, I can see that that the validate is successful. However, anytime I try post an event from within the container, I get connection refused. I think the issue lies with the certificate but I'm a bit stuck.
dotnet dev-certs https --trust
The above command doesnt work within the docker workspace as its Linux. If I try the below, it says a valid HTTPS cert already exists.
dotnet dev-certs https --export-path ./docker/azureEventGridSimulator.pfx --password Y0urSup3rCrypt1cPa55w0rd!
Any thoughts?
Thanks @AndreyBespamyatnov,
I'm using the image from docker hub.
Yeah, sounds like the SSL issue, have you checked that you added your certs to the trust store in the docker and locally?
I have tried to create the cert and add to docker but still no luck.
This is what I tried so far.
Added to /usr/local/share/ca-certificates/
Ran update-ca-certificates
After doing the above and running curl CMD, i still get the same connection refused error.
Am I doing something obviously wrong?
Hi, can you try this...
1) In Docker... open the terminal for the running container...
2) navigate to the folder containing your cert (in the default example script this will be the aegs
folder...
3) when you ls
in that folder you should see your certificate there. If you don't then something has gone wrong with the volume binding. The simulator won't be able to find your cert and therefore can't accept any SSL connections.
In your example it looks like you are mounting volume .
but then the certificate you are referencing is in /usr/local/share/ca-certificates/
- is this folder definitely being shared? perhaps navigate to this folder and check it contains the cert as you expect.
Hey, I had same issue and followed @pmcilreavy post to investigate if my cert is inside docker. That was handy. Once cert appeared inside docker, all started working.
I see differences between our configurations. Take a look, it may help you:
Try to change volumes to: volumes:
Env variable to:
Execute command to get your cert: dotnet dev-certs https --export-path ./docker/azureEventGridSimulator.pfx --password
I will close this as there has been no further activity. Hopefully, your issue is now resolved if you follow my suggestion above.
Hi all,
I am wondering if anyone has had luck running the emulator on docker? I am running docker on WSL2 am have been facing issues connecting to the endpoints.
Using the postman collection provided, I receive Error: connect ECONNREFUSED 127.0.0.1:60101. I have run the command to generate the certificates but am still facing issues.
Is there a more detailed example anywhere?