Configure custom port on Azure App Services with containers - azure

I'm creating an App Service with containers in Azure but in logs I found out that when docker run command is executed, always takes port 80 for starting application, however my application in container is listening on port 5000. How I can change it in order to take port 5000 insted of 80 when it execute docker run command?

Had the same issue, you can either use Azure CLI to set:
az webapp config appsettings set --resource-group <resource-group-name> --name <app-name> --settings WEBSITES_PORT=5000
Or add directly from Azure Portal:
Hope if helps.

Related

Reset Node app on Azure to the default container image

I've created a Node 14 Web app on Azure. For Publish, I chose Code (not Container). Then I've changed the default container image with az webapp config container set. Question, how can I revert that to the default image (which was NODE|14-lts)?
Running az webapp config container set --docker-custom-image-name 14-lts resets it to DOCKER|14-lts, which is not the same.
Running az webapp config container set --docker-custom-image-name "NODE|14-lts" produces an error.
We have tested in our local environment(created a webapp with Linux as runtime ) below findings are based on the analysis.
If you are using docker container as publish mode then LinuxFxVersion value will be "DOCKER|node:14-lts" you cannot change the value of LinuxFxVersion to "NODE|14-LTS".
If you want "NODE|14-LTS" value in LinuxFxVersion in the site properties
you need change the publish mode from docker container to code mode by using the below cmdlet.
az webapp config set --name <webappName> --resource-group <resourceGroupName> --linux-fx-version 'Node|14-LTS'

How to add additional options to docker run on Azure Service App

I am trying to run docker run -i --rm -d --cap-add=SYS_ADMIN --name <azure-container> <azure-container-registry>/<image-name>:<tag>
By default the container is created using docker run -p port1:port2
I want to remove the -p option and add --cap-add=SYS_ADMIN , every time my container gets created from azure container registry using App Service.
Any help appreciated.
Regards,
Aarushi
Unfortunately, the docker command cannot be custom when you deploy your image to Azure Web App. It runs by Azure. You can add the environment variables in the App Setting, but not change the docker command.
You cannot run a container without exposing a port, on App Services. It needs to run a server process in order to become 'healthy'. You can use port 80 (default) or 8080.
Also, as Charles Xu said, you cannot add capabilities at this time.
In Service Fabric you have more port mapping options, but you should still expose a port for the liveness probe.
No cap-add support here either.

After deploying docker container in Azure. If I browse the url its giving me connection timeout

I am deploying the image https://hub.docker.com/r/codercom/code-server which is remote VS code.I have deployed this in Azure as steps mentioned in the link https://learn.microsoft.com/en-us/learn/modules/run-docker-with-azure-container-instances/2-run-aci. After deployment is successful if I browse it , its showing connection timeout
I don't know how do you deploy the container in Azure. But on my side, it works well and finally, you can see the login page as below:
I think the possible reason is that you forget to change the port into 8080 as the image shows. You can the example command:
docker run -it -p 127.0.0.1:8080:8080 -v "$PWD:/home/coder/project" codercom/code-server
So the image exposes the port 8080 which you also need to do like it did. Then the CLI command should be:
az container create -g your_group -n aci_name --image codercom/code-server --ip-address Public --ports 8080

Deploy azure container registry images into an azure web app with docker-compose

I'm trying to run a multicontainer web app based in two images that I stored in an azure container registry (launched with a docker compose yml custom file) but it fails because the docker-compose proccess cannot get the images due to an "unauthorized: autentication required" response. Both the container registry and the web app belongs to the same resource group.
How can we solve this problem? Thanks in advance.
#jennylwrnce from Azure Developer App Service Team tweeted this:
https://blogs.msdn.microsoft.com/appserviceteam/2018/06/27/use-acr-for-multicontainer-web-app/
So it can be solved via panel.azure.com
enter image description here
You need to configure authentication for the webapp, by default it can only pull public images.
this is the sample command to do that:
az webapp config container set --name <app_name>
--resource-group myResourceGroup
--docker-custom-image-name <azure-container-registry-name>.azurecr.io/mydockerimage
--docker-registry-server-url https://<azure-container-registry-name>.azurecr.io
--docker-registry-server-user <registry-username>
--docker-registry-server-password <password>
https://learn.microsoft.com/en-us/azure/app-service/containers/tutorial-custom-docker-image#use-a-docker-image-from-any-private-registry-optional
this article also talks about how to push to the private repo (ACR) and how to configure it

Can't deploy container registry to web app for container

I tried to create test project with docker support (windows container) and deploy it to azure container registry. After that i tried "Deploy to web app" function from menu and after successful deploy only thing i can see on my resource is "Your App Service app is up and running" and i can't access my pages of methods from my app. What can be done with this?
Try to set WEBSITES_PORT configuration in your WebApp. In general the WebApp Service should detect the open port automatically and match it to 443 or 80 but in some cases it helps to set WEBSITES_PORT in the WebApp Configuration.
You can do this for example via CLI command az webapp config appsettings set --name <myname> WEBSITES_PORT='3000'.
You should restart the application afterwards.

Resources