Azure Functions with docker: How change port? - azure

I have built a docker image using Spring Native. The Spring Boot application inside the container listens on port 80 but crashes on Azure Functions on startup because of missing access rights (it seems docker doesn't allow usage of ports bellow 1024). How can I change the port Azure Functions uses for accessing the application inside the docker image?

If you are using 80 or 8080, azure will auto-detect the used port.
Every other port can be configured using WEBSITES_PORT environment variable "Function App -> Settings -> Configuration -> New application settings" to something like 8081 (or that one, which the app listens on).

Related

Application deployed in Azure VM

I have a react application deployed using an Azure virtual machine. To access the app I need to use configured DNS, for example, "http://XYZ.eastasia.cloudapp.azure.com:3000". However, I don't want to include the port num in the URL. How can I port forward in azure so that only by typing 'http://XYZ.eastasia.cloudapp.azure.com' should be enough to access the application?
If you want to users access your app by URL: http://XYZ.eastasia.cloudapp.azure.com, you should run your react app on 80 port. Refer to this post to specify a port to run react app.

Nodejs Loopback how to access api end points on live server?

I'm trying to deploy a Loopback project to live server, all works well on local. On server, after running node ., I get the console log of:
Web server listening at: http://domainname:3000
Browse your REST API at http://domainname:3000/explorer
So it looks like the server is running.
Problem is that I get no response from the server. Neither from domain:3000 or /explorer or any endpoint I created.
Does anyone know what might be the issue?
Thank you very much
I had a similar problem when I was trying to deploy my code. Some of the possible solutions to the problem depending on where and how you are deploying it-
Check if your security group allows connections on port 3000. AWS EC2 by default closes all ports except port 80. You might have to add an exception to your security group and allow port 3000 to be accessed from everywhere.
If you are using a container, check if your container has the ports open and if the container port is accessible by the hardware hosting the container. On Azure, I faced this problem as Azure Web App Container Service by default only listens to port 80 and 8080. So I had to modify my code such that it can use the default NODE_ENV.PORT or 8080.

Azure WebApp for containers without exposed ports

I have a custom built docker image which purpose is to process files that are loaded into a storage account or service bus. The container has no exposed ports.
I can deploy this image and start the container on the Azure Web App but after 240 seconds the container seems to terminate. The logs indicate that the container did not start within the time limit.
Am I correct in assuming that if no ports are exposed in my container that the webapp thinks that the container was not started correctly?
What is the best alternative for deploying my container if this is the case? (ACI, ACS, AKS,.. ?)
Azure Load Balancer has a default idle timeout setting of four minutes. This is generally a reasonable response time limit for a web request. If your webapp requires background processing, it is recommended to use Azure WebJobs. The Azure web app can call WebJobs and be notified when background processing is finished. You can choose from multiple methods for using WebJobs, including queues and triggers, see https://learn.microsoft.com/en-us/azure/app-service/web-sites-create-web-jobs
Checkout the FAQs here: https://learn.microsoft.com/en-gb/azure/app-service/containers/app-service-linux-faq
Can I expose more than one port on my custom container image?
We do not currently support exposing more than one port.
My custom container listens to a port other than port 80. How can I configure my app to route requests to that port?
We have automatic port detection. You can also specify an app setting called WEBSITES_PORT and give it the value of the expected port number. Previously, the platform used the PORT app setting. We are planning to deprecate this app setting and to use WEBSITES_PORT exclusively.

Azure web app for containers deploy with custom docker run command

Consider a docker image containing a React UI and a Spring REST app. I'd like to deploy this to Azure web app for containers, where the URL for the instance hits the UI which is being statically served on port 5000 while the Spring app is listening on 8080. The UI communicates with the Spring app via HTTP, hence the requests made by the UI to the Spring app are evaluated on the user's machine (i.e. can't access the Spring app via localhost:8080). However, port 8080 is not mapped in the default run command. Another issue is that there is only one URL for the web app.
The default run command is: (from logging in via FTP and examining docker logs)
docker run -d -p <WEB_APP_PORT>:<UI_PORT> --name ... -e ... <IMG>
Can I run a custom docker run command to expose the UI_PORT and the SPRING_PORT and also set up one web app with two URLs?
If not, are there alternative solutions?
For context:
The final image is built by extending an image which contains only the Spring app (i.e. FROM openjdk:8-jdk-alpine) and installing node and the UI.
An entrypoint.sh script start both the UI and the SPRING APP
The ports exposed in the image are 8080 and 5000.
A diagram of what I'm trying to achieve:
No, you can't do what you want with "Azure web app for containers", that platform lets you run a single container image that is mapped to ONLY one URL, and you can ONLY export web ports (80, 443) to the world, and SSH (2222) to their internal "kudzu" service.
Being "purist", you are describing a "microservice stack", so you have to go with a full container orchestration, like "Azure Container Service" (AKS, using Kubernetes), or "Azure Service Fabric" (which looks it will be awesome when they reach their goals).
However, you could get it done by internally running a "mapping service", like an Nginx proxy which would send "/" to the localhost:8080 UI and /api to localhost:5000 Spring API, or any of the techniques traditionally used for Single-page-Application "routing".
It's a decision between putting all your services inside a single container behind a single URL (microservice in a container) or putting every process in a container on a container orchestration platform (the former is cheaper in time and cost of running it, the later is more "elegant" and flexible but requires more time to build the management and is more expensive to run).

Starting new port on Amazon Ec2 free tier for socket io

I am using Amazon EC2 service for the web purpose. I have a web application which is hosted on apache i.e port 80. Now i am running a node instance on port 3000 and when i load my website.
io.connect('http:IP ADDRESS:3000');
This code tries to connect to my port. On server side my instance is started. But when i load my we application, this doesnt connect to server.
I was wondering do i need to update my configuration or is there any network settings i need to do ?
Try adding your port in your defined security group.
Follow http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/using-network-security.html#concepts-security for more reference.

Resources