0

I've followed getting started with Logic Apps in a Container, in Azure Tips & Tricks #311, which worked OK. I also consulted Vinnie James, which is similar

The Logic App runs on receipt of a HTTP request, which - inside VS Code - is localhost, easily used from a browser

But when I go to the next step, to build an image and run it in Docker, I'm not at all clear how to to make a similar HTTP request; Docker is running on the same W10 machine, using WSL-2

Dockerfile (corrected):

FROM mcr.microsoft.com/azure-functions/dotnet:3.0.14492-appservice
ENV AzureWebJobsStorage=DefaultEndpointsProtocol=https;AccountName=XXX;AccountKey=XXX;EndpointSuffix=core.windows.net
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true \
    FUNCTIONS_V2_COMPATIBILITY_MODE=true
ENV WEBSITE_HOSTNAME localhost
ENV WEBSITE_SITE_NAME testqueue1
ENV AZURE_FUNCTIONS_ENVIRONMENT Development
COPY . /home/site/wwwroot

Attempted Docker run: docker run -p 80:7071 image1

Response is HTTP request sent, awaiting response... No data received

This despite (very simple) Logic App issuing a 200 response immediately after trigger; looks like App is not initiated ...

JohnD
  • 187
  • 11
  • Can you provide which is the Dockerfile you're using and the command you use for deploying the container on your machine? – Daniel Campos Olivares Nov 15 '21 at 18:07
  • FROM mcr.microsoft.com/azure-functions/node:3.0 ENV AzureWebJobsStorage DefaultEndpointsProtocol=https;AccountName=XXX;AccountKey=XXX;EndpointSuffix=core.windows.net ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true \ FUNCTIONS_V2_COMPATIBILITY_MODE=true ENV WEBSITE_HOSTNAME localhost ENV WEBSITE_SITE_NAME test1 ENV AZURE_FUNCTIONS_ENVIRONMENT Development COPY . /home/site/wwwroot
    Deployed: docker run -p 5000 image1
    Docker desktop shows running OK, just don't know how to make HTTP call to it
    – JohnD Nov 16 '21 at 12:38

1 Answers1

0

First of all and regarding the answer in the comments: please just add the contents of the Dockerfile and the run command to the question, otherwise they're difficult to read.


Taking into account that you have the following Dockerfile:

FROM mcr.microsoft.com/azure-functions/node:3.0

ENV AzureWebJobsStorage DefaultEndpointsProtocol=https;AccountName=XXX;AccountKey=XXX;EndpointSuffix=core.windows.net 
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true \
    FUNCTIONS_V2_COMPATIBILITY_MODE=true 
ENV WEBSITE_HOSTNAME localhost 
ENV WEBSITE_SITE_NAME test1 
ENV AZURE_FUNCTIONS_ENVIRONMENT Development 

COPY . /home/site/wwwroot 

and that you're running it with docker run -p 5000 image1

The main thing that I see here is that you're only indicating the containerPort but not the hostPort, so you're exposing a random port in the host.

If you do docker ps, you'll be able to see the port that you're forwarding. For example let's say that I have my image busybox and that I run it with docker run -it --rm -p 5000 busybox.

❯ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED         STATUS         PORTS                     NAMES
05927642abfc   busybox   "sh"      6 seconds ago   Up 5 seconds   0.0.0.0:51883->5000/tcp   elated_gauss

As you can see, I'd have to access to the port 51883 in localhost to access to the port 5000 in the container.

On the other hand, if I run my container with: docker run -it --rm -p 5000:5000 busybox

❯ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED        STATUS        PORTS                    NAMES
c0aab9646d1a   busybox   "sh"      1 second ago   Up 1 second   0.0.0.0:5000->5000/tcp   busy_roentgen

Now I can access to the port 5000 of the container referring to the port 5000 on localhost.

Daniel Campos Olivares
  • 2,262
  • 1
  • 10
  • 17
  • Thanks, that helps; what I'm trying to do is to reproduce, with Docker, the basic test I'm able to do with VS Code; my test app is triggered by an HTTP request; the URL is available in VS Code; can I use the same URL in Docker? When I try to do just that, I get an error: fail: Host.Startup[515] A host error has occurred during startup operation '802c4140-a059-46b9-9a67-abbdda402c9e'. Microsoft.Azure.Storage.StorageException: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. Suggests the URL is incorrect? – JohnD Nov 17 '21 at 11:37
  • No, it means literally that you're trying to access somewhere without providing the correct Authorization. Also, you're using the `node` image from Azure functions but afterwards you're passing the contents to `/home/site/wwwroot` and exposing the port 5000, why? You should check first how Docker works for `node` applications, and afterwards adapt that to your explicit case. – Daniel Campos Olivares Nov 17 '21 at 11:51
  • Yeah, got Dockerfile wrong - sorry - am new to all this; corrected above; it's a Logic App, based - I understand - on .NET, not Node at all; I'm now getting `HTTP request sent, awaiting response... No data received` - see edited original question. Still something basic wrong, it looks. Any tips appreciated – JohnD Nov 17 '21 at 15:27
  • Can you explain why are you pairing the `hostPort` 80 to the `containerPort` 7071? AFAIK `dotnet:3.0.14492-appservice` exposes the service in the port 80 on the container. – Daniel Campos Olivares Nov 17 '21 at 15:31
  • OK, re-done now and got to the point where the Logic App in the Container is being called successfully, but I don't know how to examine what's going in _inside_ the Logic App i.e. in the way you can do in the Azure Logic App runtime ... is this available somewhere? The Docker Logs tell you that it was initiated - or not, but not that detail – JohnD Nov 19 '21 at 15:09