Blog Post

Azure Database for MySQL Blog
7 MIN READ

Deploy a Magento Open Source LAMP-stack e-commerce app on Azure with one click!

NeilDsouza's avatar
NeilDsouza
Icon for Microsoft rankMicrosoft
Nov 21, 2024

A comprehensive guide on a fully automated JSON template that enables one-click deployment through Azure Resource Manager (ARM) with minimal user inputs, allowing you to quickly set up your Magento Open Source e-commerce web application on Azure.

What is Magento Open Source?

Magento Open Source is a free and flexible e-commerce platform that allows you to create and manage online stores. It offers powerful features such as product catalog management, shopping cart, checkout, payment, shipping, marketing, analytics, and more. Magento Open Source is also highly customizable and extensible, enabling you to tailor your store to your specific needs and preferences.

Thousands of merchants around the world, ranging from small businesses to large enterprises, use Magento Open Source. The platform is also supported by a vibrant community of developers, partners, and enthusiasts who contribute to its development and improvement.

Why host Magento Open Source on Azure?

Azure is a cloud computing platform that provides a range of services and solutions for hosting, developing, and managing applications. Hosting Magento Open Source on Azure offers many benefits, such as:

  • Scalability: You can easily scale your Magento Open Source store up or down according to your traffic and demand without compromising performance or availability.
  • Reliability: You can rely on Azure's global network of datacenters and regions to ensure your store is always online and accessible to your customers.
  • Security: You can protect your store and data from cyberattacks and breaches with Azure's built-in security features and compliance standards.
  • Cost-efficiency: You can optimize your cloud spending by paying only for what you use with Azure's flexible pricing models and tools.
  • Integration: You can integrate your Magento Open Source store with other Azure services and third-party applications to enhance your e-commerce capabilities and customer experience.
  • Efficiency: You can optimize the use of your resources and reduce the overhead associated with managing and maintaining your infrastructure.
  • Resilience: You can ensure the high availability and fault tolerance of your Magento Open Source store by using Kubernetes features such as load balancing, service discovery, health checks, and self-healing.
  • Flexibility: You can scale your Magento Open Source store horizontally or vertically by adding or removing nodes or pods according to your needs and business demands.
  • Modularity: You can modularize your Magento Open Source store and dependent components into microservices and deploy them as independent and interchangeable containers.

Deploying Magento Open Source on Azure 

The single-click Azure Resource Manager (ARM) template we've provided creates and deploys the following resources in your Azure account with minimal effort required from your end:

  1. An Azure virtual network with a subnet and a network security group.
  2. A secret that stores the Magento Open Source credentials and encryption keys.
  3. A public IP address and a load balancer.
  4. An Azure Database for MySQL - Flexible Server PaaS database for Magento Open Source, the best place for MySQL on Azure.
  5. A storage account for Magento Open-Source media files. A persistent volume claim and a storage class that provide persistent storage for Magento Open-Source data.
  6. Azure Content Delivery Network (CDN) to store static files, CSS, scripts, images. (Requires SSL/TLS enabled)
  7. A deployment of Azure Kubernetes Services (AKS) which is the best managed service platform on Azure to deploy and run Magento Open Source as it achieves optimized compute resource utilization via Kubernetes which is an open-source system that automates the deployment, scaling, and management of containerized applications. It includes:
    • A specified number of pods that run Magento Open-Source containers.
    • An Elasticsearch subchart that deploys an Elasticsearch cluster for Magento Open-Source search functionality.
    • A Redis subchart that deploys a Redis server for Magento Open-Source session and page caching.
    • A service that exposes the Magento Open-Source pods to the internet.
  8. A temporary Azure VM to run automation scripts to configure AKS cluster with pods and containers.

The image below illustrates the architecture of the Magento deployment on Azure.

Image 1. Magento Open Source packaged application on Azure Architecture

Steps to deploy Magento on Azure

For step-by-step instructions on deploying Magento on Azure, you can either watch the demo video below or continue reading this section.

 

Video 1. Demo - 'How to deploy Magento Open Source on Azure in one click!' by Olcay Çelik

Prerequisites

Before running the template to deploy Magento on Azure, you need to create a Resource Group, obtain authentication keys from Adobe and configure RBAC Roles to grant permissions to the Azure VM to run the script.

  1. Create a Resource group in your Azure Subscription to deploy the Magento solution. Please note that a second resource group will be automatically created for the AKS-specific infrastructure deployment, using the name of the resource group you created as a prefix.
  2. Get your authentication keys from Commerce Marketplace. You may need to register and generate the public and private keys. For more information, see the Adobe document Get your authentication keys.
  3. Create an RBAC Role and assign necessary permissions by running the following commands from the Azure CLI:
az login # <Does not apply to Azure CLI in Azure Portal> 
az account set --subscription <Subscription_Id/Name> # <Applicable if multiple subscription associated with Azure account> 
az ad sp create-for-rbac --name magento2 --role "Azure Kubernetes Service Contributor Role" --scopes /subscriptions/<Subscription_Id>/resourceGroups/<Resource_Group> 
az role assignment create --assignee <AppId> --role "CDN Profile Contributor" --scope /subscriptions/<Subscription_Id>/resourceGroups/<Resource_Group> 
az role assignment create --assignee <AppId> --role "Virtual Machine Contributor" --scope /subscriptions/<Subscription_Id>/resourceGroups/<Resource_Group>

Be sure to save the output from the above command, as you'll need to input this information into the template during the deployment steps.

HTTPS using SSL

It is highly recommended to use SSL encryption with TLS 1.2 or higher to safeguard users of the Magento e-commerce application when connecting over the HTTPS protocol, adhering to open-source industry standards. Follow the steps below to configure SSL:

  1. Create key vault in the same resource group that you created in the prerequisite steps.
  2. Import your TLS certificates to the same key vault.

Note: SSL/TLS is mandatory to enable Azure CDN.

One-click deployment link

Description

Deployment link

Magento and its pre-requisite components – Varnish (Load Balance/Traffic Manager), Elasticsearch (full text search), Redis (cache) hosted on Azure Kubernetes Services (AKS) Container PODs as infra, Azure Container Registry to maintain the container image and its updates and deployment, Azure Database for MySQL - Flexible Server for RDBMS, Azure CDN and Azure Premium File Storage for content.

 

 

 

Essential inputs for deployment

The following configuration values are a must for the deployment, some of which you'll obtain in the prerequisite steps:

Configuration

 Description

Service Principal App ID

The Service Principal App ID from the output of the Azure CLI commands to create the RBAC roles in the earlier steps.

Service Principal Password

The Service Principal App Password from the output of the Azure CLI commands to create the RBAC roles in the earlier steps.

Composer Username

The public key from the authentication access keys generated at Commerce Marketplace.

Composer Password

The private key from the authentication access keys generated at Commerce Marketplace.

Magento Admin Password

The password for the Magento administrator.

MySQL Administrator Password

Admin password for Azure Database for MySQL server.

VM Admin Password

Admin password for the temporary virtual machine used for AKS setup.

Magento Admin Email

The email address for the Magento admin.

Storage Account Name

The unique name for Azure Storage Account to host Magento content.

Advanced Customization (Optional)

For advanced configuration and customization of the solution during deployment, please refer to the ReadMe file in the GitHub repository hosting the one-click template:

While compute SKUs can be scaled up or down post-deployment based on your workload testing, the following settings must be configured at deployment time:

  • Magento Admin Username
  • MYSQL Administrator Login
  • Kubernetes System Node Pool VM Size
  • Azure CDN
  • SSL Encryption TLS
  • Resource Name Prefix
  • Key Vault Name
  • Certificate Name
  • External FQDN
  • MySQL Database Name
  • MySQL Version
  • MySQL Availability Zone
  • MySQL High Availability
  • MySQL Standby Availability Zone
  • MySQL Geo Redundant Backup

Note: For information about troubleshooting deployment errors, see the article Troubleshoot common Azure deployment errors.

 

IMPORTANT: After the ARM template deployment is complete, be sure to navigate to the AKS cluster and ensure all the AKS deployment and configuration jobs are completed. You may notice couple of deployment/configuration jobs named ‘magento-server’ and ‘magento-cron’ are still running for short time after ARM deployment is completed. Navigate to the application URL only after all the jobs have completed.

Image 2. ARM template deployment has completed, but the AKS workloads are getting configured.Image 3. Deployment and configuration of Magento Open Source packaged application solution has completed.

Post-deployment steps

After the deployment, you can reach the Magento application by navigating to the 'Services and Ingresses' blade and locate the external IP address of the load balancer service that exposes the Kubernetes pods to the internet. 

Image 4. Obtain the External IP address of the AKS Load Balancer exposing the Magento app to internet.

Navigate to the IP Address (in this example '20.227.97.109') from any modern browser to get to the Magento application Home Page. The website is blank as the Magento database has no data. You can load your data to the Azure Database for MySQL server for the Magento application to use.

Image 5. Fully deployed Magento Open Source packaged application on Azure

To configure Magento application settings, administrator(s) can reach the administrator login page by navigating to the address '<external IP address>/admin' (in this example '20.227.97.109/admin')

Image 6. Magento admin login page to configure and administer the Magento Open Source application

Conclusion

In conclusion, this solution simplifies the deployment and optimal operation of the Magento Open Source e-commerce web application platform on Azure. It ensures seamless integration with various Azure infrastructure components, including Virtual Network, AKS, Private Endpoint, Azure CDN, Azure Premium File Storage, Azure VM, and Azure Database for MySQL, the highly preferred open-source RDBMS option on the cloud which supports not only Magento but also other widely used LAMP stack applications such as Moodle and WordPress.

Leverage this one-click deployment template to host your e-commerce web application on Magento on Azure today!

If you have any queries or suggestions, please let us know by leaving a comment below or by contacting directly us at AskAzureDBforMySQL@service.microsoft.com

Updated Dec 04, 2024
Version 4.0
No CommentsBe the first to comment