VSTS push docker-compose to Azure Container Registry and WebApp - azure

I would like to configure continuous integration from VSTS to Azure Container Registry and then to WebApp.
Here's my docker-compose.yml file:
As you can see I'm using an Asp.Net core + mssql.
version: '3'
services:
api:
image: tbacr.azurecr.io/myservice/api
container_name: api
build:
context: ./Api
dockerfile: Dockerfile
ports:
- "8000:80"
depends_on:
- db
db:
image: "microsoft/mssql-server-linux"
container_name: mssql
environment:
SA_PASSWORD: "testtest3030!"
ACCEPT_EULA: "Y"
MSSQL_PID: "Developer"
ports:
- "127.0.0.1:8001:1433"
Here's my task from VSTS:
And I think the major task is Build Services and PublishServices
So, please take a look below:
Build Services
PublishServices
And finally, in Azure Container Registry I have:
So, the question is how can I deploy it to the WebApp. I have tried right-click to api: latest repository and deploy to WebApp but the endpoint does not respond

There is 2 steps im VSTS : build and release. It seems your build part is ok. So your docker image is pushed in your repo. Then you have to configure the build part in VSTS that will get the image you just pushed on the repo and deploy it on a server.
HTH

Related

How to deploy a multi-container docker with GitHub actions to Azure web application?

I want to deploy a web application, which is built with Docker into a Azure web app.
There are a lot of tutorials and documentation about how to easily deploy a single docker image into Azure. But how to deploy multiple images into Azure?
I want to achieve this:
Local development with Docker-Compose. Works.
Versioning with GitHub. Works.
GitHub actions > Building the Docker images and pushing it to Docker-Hub (maybe not necessary, if the images are registered in Azure). Works.
Deploy everything to Azure and run the web application.
There is a similar question here: How to deploy a multi-container app to Azure with a Github action?
But I want to avoid the manual step, which is mentionend in the answer.
My docker-compose.yml:
version: '3.8'
services:
server-app:
image: tensorflow/serving
command:
- --model_config_file=/models/models.config
ports:
- 8501:8501
container_name: TF_serving
tty: true
volumes:
- type: bind
source: ./content
target: /models/
client-app:
build:
context: ./client-app
dockerfile: dockerfile
image: user1234/client-app:latest
restart: unless-stopped
ports:
- 7862:80

multi-container app build via docker-compose in Azure Container Registry work locally but fail on Azure app services

I containerized an app that has two servers to run: rasa and action_server. I used docker-compose to build the images and then pushed them to Azure Registery Container.
I run the images locally from Azure Registry Container and works fine on localhost.
However, when I deployed the app on Azure App Services, the app restarts with an error.
2022-11-04T17:57:56.583Z ERROR - Start multi-container app failed
2022-11-04T17:57:56.593Z INFO - Stopping site demosite because it failed during startup.
2022-11-04T18:01:36.904Z INFO - Starting multi-container app..
2022-11-04T18:01:36.910Z ERROR - Exception in multi-container config parsing: Exception: System.InvalidCastException, Msg: Unable to cast object of type 'YamlDotNet.RepresentationModel.YamlScalarNode' to type 'YamlDotNet.RepresentationModel.YamlMappingNode'.
2022-11-04T18:01:36.911Z ERROR - Start multi-container app failed
2022-11-04T18:01:36.914Z INFO - Stopping site demosite because it failed during startup.
docker-compose.yaml
version: '3'
services:
rasa:
container_name: "rasa_server"
user: root
build:
context: .
volumes:
- "./:/app"
ports:
- "80:80"
action_server:
container_name: "action_server"
build:
context: actions
volumes:
- ./actions:/app/actions
- ./data:/app/data
ports:
- "5055:5055"
I tried to make another app but the problem remains.
As stated in the documentation, build is unsupported. You need to modify your compose file to reference the images stored in ACR.
Also, App Service only listens on port 80/443 so you can't expose your action_server on port 5055.

Unable to create Azure App Service with Docker Compose and Mongodb

I have Azure Container Registry
xxxxxxxx.azurecr.io
Inside of it I have 1 image
learning-docker01/api
Next, I create App Service. I select Docker Container as publish option and following options:
Options: - Docker Compose (Preview)
Image Source - Azure Container Registry
Registry - xxxxxxxx
Next I select my docker-compose.yaml file. The configuration looks like this:
version: "3.4"
services:
docker001.api:
image: xxxxxxxx.azurecr.io/learning-docker01/api
build:
context: ./Docker001.API
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:80
ports:
- "8000:80"
mongo:
image: mongo
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=root
- MONGO_INITDB_DATABASE=docker
ports:
- 27017:27017
Then I hit Review & Create and everything deploys smoothly.
The problem - after deployment, if I view Log Stream (Preview) I see the following Errors:
DockerApiException: Docker API responded with status code=InternalServerError,
response={"message":"Get https://registry-1.docker.io/v2/library/mongo/manifests/latest:
unauthorized: incorrect username or password"}
----
Pulling docker image mongo failed:
---
Container for learningdocker001_mongo_0_986c7f1a site learningdocker001 is unhealthy, Stopping site.
I'm not sure what the problem is. Everything runs fine locally. On Azure docker001.api service runs but mongo service doesn't.
You need to set up authentication to allow the App Service to pull images from the ACR.
Recommended way is to use the Managed Identity. Detailed setup description here: https://learn.microsoft.com/en-us/azure/app-service/tutorial-custom-container?pivots=container-linux#configure-app-service-to-deploy-the-image-from-the-registry

Building a Docker Compose stack with Azure Container Instance

I'm using Docker Compose with Azure Container Instance service. Their docs/guides say I should be able to build custom images with that service using docker compose up -d, but the service forces me to include a pre-built image in my compose.yml. How can I deploy a web app from a Compose file so that Azure builds it too?
Here's my my desired compose file is like. Note that I use a generic Redis image, but that the DB and API both rely on other Dockerfiles to be built. I'd like to use some Azure service (I think Container Instance is the only one that supports interacting with compose files) to deploy with a single command so that my local code is pushed to some build server (or pulled using git by the build server) to build any needed images used by my compose.yml. Is this possible?
version: "3.9"
services:
db:
build:
context: docker/db
dockerfile: db.Dockerfile
restart: always
ports:
- "3306:3306"
api:
build:
context: docker/api
dockerfile: api.Dockerfile
restart: always
environment:
- MYSQL_HOST=db
- MYSQL_HOST_REPLICA=db
- REDIS_HOSTNAME=redis
ports:
- "8000:8000"
depends_on:
- db
- redis
redis:
image: redis:alpine
restart: always
ports:
- "6379:6379"

Deploying via Docker Compose to Azure App Service with multiple containers from different sources

I have a docker-compose.yml file which is created from a build step in Azure Devops. The build step works well and I can see how the docker-compose.yml file is produced. That makes sense to me.
However, it is looking for a normal docker image to run one of the services and the other service is one I've created and am hosting in my Azure Container Registry.
The docker compose file looks like this:
networks:
my-network:
external: true
name: my-network
services:
clamav:
image: mkodockx/docker-clamav#sha256:b90929eebf08b6c3c0e2104f3f6d558549612611f0be82c2c9b107f01c62a759
networks:
my-network: {}
ports:
- published: 3310
target: 3310
super-duper-service:
build:
context: .
dockerfile: super-duper-service/Dockerfile
image: xxxxxx.azurecr.io/superduperservice#sha256:ec3dd010ea02025c23b336dc7abeee17725a3b219e303d73768c2145de710432
networks:
my-network: {}
ports:
- published: 80
target: 80
- published: 443
target: 443
version: '3.4'
When I put this into an Azure App Service using the Docker Compose tab, I have to select an image tab - either Azure Container Registry or Docker Hub - I'm guessing the former because I am connected to that.
When I start the service, my logs say:
2020-12-04T14:11:38.175Z ERROR - Start multi-container app failed
2020-12-04T14:23:28.531Z INFO - Starting multi-container app..
2020-12-04T14:23:28.531Z ERROR - Exception in multi-container config parsing: Exception: System.NullReferenceException, Msg: Object reference not set to an instance of an object.
2020-12-04T14:23:28.532Z ERROR - Start multi-container app failed
2020-12-04T14:23:28.534Z INFO - Stopping site ingeniuus-antivirus because it failed during startup.
It's not very helpful, and I don't think there's anything wrong with that docker-compose.yml file.
If I try to deploy ONLY the service from the Azure Container registry, it deploys, but doesn't deploy the other service.
Does anyone know why the service doesn't start?
Well, there are two problems I find in your docker-compose file for the Azure Web App.
One problem is that Azure Web App only supports configuring one image repository in the docker-compose file. It means you only can configure the Docker Hub or ACR, not both.
Another problem is that Azure Web App does not support the build option in the docker-compose file. See the details here.
According to all the above, I suggest you can create all your custom images and push them to the ACR and use the ACR only.

Resources