Customized Container Images for Azure AppService

Create Web App wizard
Select between “Single Container” and “Docker Compose”
Azure AppService can download container images from various sources

Create a customized Container Image

Currently available PHP container images on GitHub
# Use Microsoft's PHP 7.4 image as a foundation
FROM mcr.microsoft.com/appsvc/php:7.4-apache_20200707.6
# ACCEPT_EULA is required to silently install some packages
ENV ACCEPT_EULA=Y
# Update the Ubuntu operating system and all its installed packages
RUN apt update && apt upgrade -y
# Install PHP extensions via PECL
RUN pecl install mysqlnd_azure
# Enable Azure Redirect
RUN echo "extension=mysqlnd_azure" >> /usr/local/etc/php/conf.d/mysqlnd_azure.ini && \
echo "mysqlnd_azure.enableRedirect = on" >> /usr/local/etc/php/conf.d/mysqlnd_azure.ini
# Use Microsoft's PHP 7.4 image as a foundation
FROM mcr.microsoft.com/appsvc/php:7.4-apache_20200707.6
# ACCEPT_EULA is required to silently install some packages
ENV ACCEPT_EULA=Y
# Update the Ubuntu operating system and all it's installed packages
RUN apt update && \
apt upgrade -y
# Install PHP extensions via PECL
RUN pecl install mysqlnd_azure
# Enable Azure Redirect
RUN echo "extension=mysqlnd_azure" >> /usr/local/etc/php/conf.d/mysqlnd_azure.ini && \
echo "mysqlnd_azure.enableRedirect = on" >> /usr/local/etc/php/conf.d/mysqlnd_azure.ini
docker build -t appsvc-php74-mysqlnd:latest .Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM mcr.microsoft.com/appsvc/php:7.4-apache_20200707.6
---> f8813a5c797d
Step 2/5 : ENV ACCEPT_EULA=Y
---> [..]
---> f67be3e8d490
Step 3/5 : RUN apt update && apt upgrade -y
---> Running in de14d391739d
Get:1 http://deb.debian.org/debian buster InRelease [121 kB]
Get:2 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
[..]
Step 4/5 : RUN pecl install mysqlnd_azure
---> Running in f433f3f78255
downloading mysqlnd_azure-1.1.1.tgz ...
Starting to download mysqlnd_azure-1.1.1.tgz (27,444 bytes)
.........done: 27,444 bytes
[..]
Step 5/5 : RUN echo "extension=mysqlnd_azure" >> /usr/local/etc/php/conf.d/mysqlnd_azure.ini && echo "mysqlnd_azure.enableRedirect = on" >> /usr/local/etc/php/conf.d/mysqlnd_azure.ini
---> Running in 752e515d375dSuccessfully built d2c1b847947e
Successfully tagged appsvc-php74-mysqlnd:latest
docker push heoelri/appsvc-php74-mysqlnd:latestThe push refers to repository [docker.io/heoelri/appsvc-php74-mysqlnd]
f8699c0b9ff7: Preparing
6a3bc25c5427: Preparing
[..]
9ed763c36c1d: Layer already exists
0b1953527add: Layer already exists
[..]
Our custom container image hosted on Docker Hub

Deploy App Service using a custom container image

Azure AppService Docker container image source
Azure AppService deployment wizard summary
2020-11-25T14:34:05.299Z INFO  - Docker Hook Operation 9b28ec38-d4ed-4528-b2d1-a249a0276ea1 successful, Time taken: 0 Minutes and 1 Seconds
2020-11-25T14:34:05.329Z INFO - Starting container for site
2020-11-25T14:34:05.332Z INFO - docker run -d -p 4568:80 --name customized_3_4cc68609 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=customized -e WEBSITE_AUTH_ENABLED=False -e PORT=80 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=customized.azurewebsites.net -e WEBSITE_INSTANCE_ID=a087bea19439345db21a76f88594d305d37fb4f2015dfe09924ae07097ffb97b heoelri/appsvc-php74-mysqlnd:latest

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store