microsoft / azure-container-apps

Roadmap and issues for Azure Container Apps
MIT License
362 stars 29 forks source link

How do I set the port mapping for the side car??? #1180

Closed mikedice closed 3 months ago

mikedice commented 4 months ago

Please provide us with the following information:

This issue is a: (mark with an x)

Issue description

I want to deploy a container app that consists of two containers. One container is implementing a web application (SPA like web app with a few server side features). I wanted to enhance this app with the ability to perform CRUD operations on Azure Storage. I thought it would be cool to split out the whole storage piece into a side car so I made another app that implements all the storage authorization and access. On localhost, this is how the sidecar container gets started:

docker run --rm -p 2112:2112 --env-file ./.env --env AZURE_CLIENT_SECRET="$us" --env AZURE_CLIENT_ID="$cid" --env AZURE_TENANT_ID="$tid" la-puerta-b-api:1 

Inside the side car container NodeJS with Express is running and a bunch of Azure stuff. On my localhost, the web app accesses the side car using URLs like http://localhost:2112/api/xxx. All this works fine on my localhost

Now I want to deploy all of this into my Azure container app. However, I cannot find anywhere in the Azure Portal where I can tell the container app that the la-puerta-b-api container needs to map port 2112 from inside the container to port 2112 on the host so that http://localhost:2112/api/xx will work in the container app. Since I cannot figure out how to configure the port mapping on the sidecar, the app gets a connection error when it tries to connect to http://localhost:2112/api/xx

My container app sidecar exploration has failed and now I am stuck.

Steps to reproduce

  1. I am using Azure Portal to deploy and configure everything

Expected behavior [What you expected to happen.] A port mapping field somewhere that I can set the port mapping for the side car

Actual behavior [What actually happened.] No place that I can see or find that says how to set the port mapping for the side car. I am stuck

anthonychu commented 4 months ago

You don't need to specify the container port. All containers share networking and can reach each other on localhost. So you just need to start the sidecar container as usual, and it'll listen to 2112. Your main app would listen to a different port. If you want to expose the main app outside the environment, you would enable external HTTP ingress and set the target port to the main app's port. Let me know if that works.

microsoft-github-policy-service[bot] commented 3 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.