Notes from:
https://learn.microsoft.com/en-us/training/modules/deploy-run-container-app-service/?source=learn
https://code.visualstudio.com/docs/containers/app-service#:~:text=In%20Docker%20Explorer%2C%20navigate%20to,must%20be%20unique%20across%20Azure.
Creation of the WebApp Service
In vscode, docker extension, rightclick the image -> Push -> Follow the instructions to correctly tag the image, and create a new webapp if required.
The image is uploaded and build in the container registry. The WebApp is setup to CI/CD from the container registry.
Debugging / Logging
When in the webapp service -> deployment center -> logs, we find logs of the webservice. Sequency of the output log looked like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| 2024-02-27T12:30:40.375Z INFO - Pulling image: gisprojectcontainerregistry.azurecr.io/gisproject-server:latest
2024-02-27T12:30:40.643Z INFO - latest Pulling from gisproject-server
2024-02-27T12:30:40.667Z INFO - Digest: sha256:825d3e57433b9eb25c859b00c822c5e995a41b012ed6943c3dbd71e93b85ca9c
2024-02-27T12:30:40.669Z INFO - Status: Image is up to date for gisprojectcontainerregistry.azurecr.io/gisproject-server:latest
2024-02-27T12:30:40.689Z INFO - Pull Image successful, Time taken: 0 Seconds
2024-02-27T12:30:40.843Z INFO - Starting container for site
2024-02-27T12:30:40.845Z INFO - docker run -d --expose=8000 --name offshorewindgis_0_4ae85d23 -e WEBSITE_USE_DIAGNOSTIC_SERVER=false -e WEBSITE_SITE_NAME=offshorewindgis -e WEBSITE_AUTH_ENABLED=False -e PORT=8000 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=offshorewindgis.azurewebsites.net -e WEBSITE_INSTANCE_ID=619d5cd37d5df35ce07c198c9a607841d32e50136529316925bc0449d5dc307e gisprojectcontainerregistry.azurecr.io/gisproject-server:latest
2024-02-27T12:30:40.847Z INFO - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2024-02-27T12:30:43.473Z INFO - Initiating warmup request to container offshorewindgis_0_4ae85d23_msiProxy for site offshorewindgis
2024-02-27T12:30:43.521Z INFO - Container offshorewindgis_0_4ae85d23_msiProxy for site offshorewindgis initialized successfully and is ready to serve requests.
2024-02-27T12:30:43.523Z INFO - Initiating warmup request to container offshorewindgis_0_4ae85d23 for site offshorewindgis
2024-02-27T12:30:46.937Z ERROR - Container offshorewindgis_0_4ae85d23 for site offshorewindgis has exited, failing site start
2024-02-27T12:30:46.945Z ERROR - Container offshorewindgis_0_4ae85d23 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2024-02-27T12:30:47.048Z INFO - Stopping site offshorewindgis because it failed during startup.
|
Does not make much sense. To find the actual problem, go to your-app-service -> Diagnose and solve problems -> Application logs.
Here, I found out the python error supplied by the container (originating in this case from azure.py).
Create an Azure Container Registry
Azure Container Registry provides storage for Docker images in the cloud.
Either create it in the Azure portal, or with the Azure CLI or Cloud Shell (icon in the toolbar of Azure portal) using:
1
| az acr create --name myregistry --resource-group mygroup --sku standard --admin-enabled true
|
You can ofcourse build you image locally yourself, or upload the Docker file and other files and let Container Registry build it:
1
| az acr build --file Dockerfile --registry myregistry --image myimage .
|
The ‘.’ at the end points to the repository, so make sure you are in the correct folder or use the path.
Problem solution: No Azure environment variables available in container
Use the following magic in entrypoint.sh, before the runserver call:
1
| eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile)
|
It copies all environments of the azure environment to the container environment.
Use local az CLI
After installation, access from cmd (or PowerShell but fuck PowerShell).
Type:
This will redirect to a web login.
Difference between Container Registry and Container Instances
The one registres, while the other actually instantiates? No clue.
Problems resolve
As with everything Microsoft, it rarely actually works. I cant access the ACR.
Tried solves:
https://stackoverflow.com/questions/77982084/how-to-fix-tasksoperationsnotallowed-acr-tasks-requests-for-the-registry-cont
https://learn.microsoft.com/en-us/answers/questions/1530524/how-to-fix-(tasksoperationsnotallowed)-acr-tasks-r
I have downloaded docker desktop for windows.
I will always create the containers locally or via Docker Hub because FUCK MICROSOFT.