e-Zest members share technology ideas to foster digital transformation.

Containerized Magento Application Deployed on Azure Web App for Containers

Written by Pramod Farate | May 30, 2019 1:01:00 PM

Magento is an open source technology for e-Commerce platform. The platform makes it flexible and easy for merchants to control overall shopping cart system. It also provides powerful search engine optimization and powerful marketing. Containerizing Application is efficient as well as lightweight.

Azure Web App for Containers helps to smoothly deploy and run the containerized application on both Windows or Linux based environment. You can at any time scale up or scale down (For Web App for Container) as per your business needs.

Currently, we are deploying the Magento application as well as the database in the same Web App.

In this blog, my focus will be on how to deploy Multi-Container Magento based application on Web App for Container.

Follow the steps below:

Step 1: First you need to have an Azure Subscription.
Step 2: Select create a resource option. Search and select Web App for Container.

Step 3: To create Web App for Containers follow steps below:

  • Enter the App Name
  • Select your Subscription
  • Create or Select Resource Group
  • Select OS Type As Linux
  • Select an existing App Service plan or create a plan for the new app
  • To Create a New App plan Follow the below steps
    For App Service plan, enter the name of the plan
    For Location, select an appropriate location
    For Pricing tier, select an appropriate pricing tier for the service and Click Ok

Note: It is recommended to use minimum Premium P1V1 as pricing tier for Magento application

Step 4: To Configure container, follow the below steps:

  • Go to Configure container
  • Select Docker Compose (Preview) - Currently this feature is in preview mode
  • Select Image Source as Docker Hub
  • Select Repository Access as Public
  • Go to Configuration file option and upload your docker compose file (docker-compose.yml)
  • After Uploading file then apply
  • Finally create the Web App for Container

Note: Replace your URL in MAGENTO_HOST with the docker-compose.yml file:
version: '2'

services:
mariadb:
image: 'bitnami/mariadb:latest'
environment:
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=bn_magento
- MARIADB_PASSWORD=your_password
- MARIADB_DATABASE=bitnami_magento
volumes:
- 'mariadb_data:/bitnami'
magento:
image: 'bitnami/magento:latest'
environment:
- MARIADB_HOST=mariadb
- MARIADB_PORT_NUMBER=3306
- MAGENTO_DATABASE_USER=bn_magento
- MAGENTO_DATABASE_PASSWORD=your_password
- MAGENTO_DATABASE_NAME=bitnami_magento
- MAGENTO_HOST=magentoapp.azurewebsites.net
depends_on:
- mariadb
ports:
- '80:80'
- '443:443'
volumes:
- 'magento_data:/bitnami'

volumes:
mariadb_data:
driver: local
magento_data:
driver: local

Step 5: After your Web App is created

  • Then select Diagnostics logs
  • Click on Application Logging and select file system
  • Then, go to Retention Period for log retention and enter the number of days (you can select retention days as per your requirement)

Step 6: Now go to Container settings then go to Logs, click on Refresh and you will see the following logs if your application is successfully deployed on Web App for container.

Step 7: Test the web app

  • To verify, select overview and click on Browse option and then you will be redirected to your application
    OR
  • Verify that the web app works by browsing to it (http://<app-name>.azurewebsites.net)

Finally you will see your Magento Application deployed through Web App for Container.