Deploying Moodle on Azure – things you should know

Published Aug 20 2019 05:41 PM 30.4K Views

Moodle is one of the most popular open source learning management platform empowering educators and researchers across the world to disseminate their work efficiently. It is also one of the most matured and robust OSS application which is developed and improvised by the community over the years. We have seen customers deploying Moodle in Azure from small, medium and large enterprises to schools, public sector and government organizations. In this blog post, I will be sharing some of the best practices and tips for deploying Moodle on Azure based on our experience working with some of our customers.



In order to deploy, customize and consume this solution, it is important you have good understanding of Azure Resource Manager (ARM) templates.


Provisioning a Scalable Moodle Cluster on Azure

To simplify the deployment and provisioning of Moodle Cluster on Azure, our engineering team has developed some canned Azure Resource Manager (ARM) templates and made it available in our GitHub repository.


If you have Azure account, you can deploy Moodle via the Azure portal using the button below, or you can deploy Moodle via the CLI. Please note that while you can use an Azure free account to get started depending on which template configuration you choose you will likely be required to upgrade to a paid account.


Below is a list of pre-defined deployment options based on typical deployment scenarios (i.e. dev/test, production etc.). All configurations are fixed, and you just need to pass your ssh public key to the template for logging in to the deployed VMs. For production deployments, large size or Maximum template below is highly recommended which provisions high performance SKUs and configures the environment for high availability.


Deployment Type


Estimated Cost



This deployment will use NFS, Azure Database for MySQL, and smaller autoscale web frontend VM sku (1 core) that'll give faster deployment time (less than 30 minutes) and requires only 2 VM cores currently that'll fit even in a free trial Azure subscription.



Small to Mid-Size

Supporting up to 1000 concurrent users. This deployment will use NFS (no high availability) and MySQL (8 vCores), without other options like elastic search or redis cache.



Large size deployment (with high availability)

Supporting more than 2000 concurrent users. This deployment will use Gluster (for high availability, requiring 2 VMs), MySQL (16 vCores) and redis cache, without other options like elastic search.




This maximal deployment will use Gluster (for high availability, adding 2 VMs for a Gluster cluster), MySQL with highest SKU, redis cache, elastic search (3 VMs), and pretty large storage sizes (both data disks and DB).




NOTE: Depending on the region you choose to deploy the stack in - the deployment might fail due to SKUs being hardcoded in the template where they are not available. If your deployment fails, please revert to the fully configurable template and change the SKU parameter to one that exists in your region (i.e. Gen-5).


The template deploys the following architecture in Azure.





Configuring Azure Database for MySQL for performance and scale

Moodle supports multiple databases like MySQL, PostgreSQL or SQL Server but the best performance and scale for Moodle is observed with MySQL database. As a result, MySQL is a preferred choice for customers and community when deploying Moodle for large number of concurrent users (1K – 10K). Azure Database for MySQL is a fully managed database service with built-in high availability, elastic scaling and automatic backups. Leveraging a managed service ensures you do not have to worry about managing your database for backups, high availability and setting up additional database monitoring.


When provisioning Azure Database for MySQL server for Moodle deployments, following is the recommended tier which provides best price to performance ratio.


Concurrent Users

Compute (vCores)

Storage Tier

< 1000 Users

8 vCores – General Purpose tier


1K – 2K Users

16 vCores – General Purpose Tier


2K – 5K Users

32 vCores – General Purpose Tier


> 5K Users

32 - 64 vCores – General Purpose Tier



If you notice, the recommendation for Storage tier is 2TB for higher concurrenct users irrespective of the size of the database. This is due to fact that in Azure Database for MySQL service, IOPs is not charged separately and it increases progressively with storage size provisioned (~3 IOPs/GB). With 2TB, you get 6000 provisioned IOPs which is recommended and required for Moodle when the number of concurrent users exceeds 1000 users.


In addition to server scaling, configuring the right server parameters also plays an important role in the performance of Moodle application as recommended in the official documentation.  You can leverage Azure portal or Azure CLI to configure the following server parameters


  1. Enable the query cache
    query_cache_type = 1
    query_cache_size = 36M
    query_cache_min_res_unit = 2K


  1. Increase the size of open table cache
    table_open_cache = 1024


  1. If you are migrating or restoring an existing Moodle database to Azure Database for MySQL service, it is recommended to perform OPTIMIZE ALL on the tables in the database following the restore. If it is a new deployment with no preexisting data, you can skip this step
    mysqlcheck -a moodle


  1. Lastly, we would highly recommend to enable Query Performance Insights on your Azure Database for MySQL server which is an opt-in monitoring feature available at no additional cost. This will enable you to monitor and identify long running and slow performing queries on the database which might lead to poor performance or slowness in the application

    Query Performance Insights can be enabled by enabling query store which requires setting the following server parameters from Azure Portal
    Set query_store_capture_mode to ALL
    Set query_store_wait_sampling_capture_mode to ALL

    To give you an example of relevance of this feature in performance tuning, I want to share the following screenshot of the Long Running Queries report for a Moodle application running 3K concurrent users which was seeing an avg response time of > 100 seconds which was unacceptable.

    After turning ON Query Performance Insights, we were able to identify the top query (Query ID 1065) in the report below which further enabled us to discover that we are hitting a known bug in Moodle causing slow performance in the application. On applying the workaround suggested in the bug tracker of truncating the expired cache in mdl_cache_flags table and creating indexes on expiry and timemodified columns, the performance was back to < 10 seconds which was expected.



  1. It is also important to check and validate that binlog and slow_query_log is disabled as it may cause additional IO overhead and adds slowness to the server for high concurrent users.
             Ensure log_bin is set to OFF
             Ensure slow_query_log is set to OFF


Finally, it is important to leverage Redis Cache for Session handling and OPCache to ensure MySQL database is not flooded with queries as caching can help alleviate a lot of pressure on the backend database and improve the overall performance and scale for the application.


Supportability of the solution

The Moodle deployment templates shared in this blog post is not a managed solution. Moodle is a third party software and Microsoft Customer Support and Services (CSS) will not supporting the solution. Microsoft only provides support for the underlying infrastructure and services used in the solution. The solution is open-source and maintained by the community of experts in GitHub and for any issues, we recommend you open an issue in GitHub. Please read the Readme and detailed FAQs documentation before proceeding with the deployment of the solution in production. 

Can I customize the templates based on my requirements?

These templates are highly configurable. Full details of configuration options can be found in the documentation (more specifically in parameters documentation).

How can I find the admin password of the Moodle site?

You can find the Moodle Administrator password and other output parameters post-deployment of the Moodle template using the following Azure CLI command.  In order to use the commands, you will need to download and install Azure CLI and provide your resource group and deployment name as the input parameters. The deployment name for your Moodle deployment can be found by viewing the deployment history in Azure portal. More details on viewing the deployment history can be found here

Moodle/ at master · Azure/Moodle (


Next Steps

Get started by deploying your Moodle application on Azure using the above template.


If you have some feedback or discover any additional finding, please reach out to us and we will be happy to incorporate it to our blog.


Parikshit Savjani
Senior Program Manager, Microsoft

Senior Member




I see this template install or use image moodle. I want to know  where I can find the credentials to login.  Thks. 

Its auto generated using the following code

"moodleAdminPass": "[concat(toUpper('xl'), substring(uniqueString(resourceGroup().id, deployment().name), 6, 7),',1*8')]",
  "moodleDbName": "moodle",
Occasional Contributor

@Parikshit SavjaniI am absolutely not experienced and looking for a good way to host moodle. I'd like to use Azure cause I work with Office365 a lot and need zo use Azure Active Directory already. But these deploying options seem really expensive to me. For the small deployment I get a cost estimate of Estimate total: $974.08. That is so much more than other hosting services offer for the complete service. I'm a getting something wrong here?

@ArneDD - Can you email us at Ask Azure DB for MySQL <> with the number of users for which you are looking to provision Moodle environment, your preferred Azure region, some more background of your requirement (what do you plan to use it for and how long) and we can see how best we can assist to meet your goal 

Established Member

@Parikshit Savjani I agree with @ArneDD that the mentioned templates are quite expensive - especially the "small" one. I did send an email with our requirements to the mentioned email address. 

When begining a project you want to start small and then scale as your demand grows. Starting with a 1.000 USD investment for a small moodle installation is not something you consider. We want to have the advantages of CLOUD services wich means start small and then grow... 


First, let me clarify on @ArneDD comment on the blog. We had a bug in our pricing calculator which quoted the price of the minimal configuration as $978 but it is actually $458 USD (depending on Azure region). However this estimation is based on the PAYG model. There are other cost optimization options which can bring your cost down signicantly to around ~$200 per month.. I have respond to your email. Let me know


Regular Visitor

hi i deployed large size installation in azure. moodle is working good. but i cant integration ldap extension. in moodle php info page, ldap must be see. i install php7.4-ldap in ubuntu. but it is not active moodle. and i cant coonect my ldap server to moodle.

Regular Visitor

I guess you'd better mind php7.4-ldap extension

Occasional Visitor

PLease, how to use htmlLocalCopy, and what are the shell commands you mean for putting moodle in maint mode, do you mean moosh?

Occasional Visitor



We have tried to restore our moodle and theme folders over the top of this setup but the site doesn't seem to be updating. Is there a command or a refresh we need to run?

Occasional Visitor


When I install any of the distributions here, it is very successful, but by default it gives a domain name or dns, we want to move it to a special dns or domain name, how can we do that? For example, I want to change the default "" domain name to "".

Thank you for your interest.

Good luck with.


Occasional Visitor

@Parikshit Savjani I need some HELP!


I get that the changes need to be done via the Controller and i understand the script you need to execute to sync the controller with the public VM nodes. What is the best way to install themes, plugins etc. Do i use the controller and then sync and then refresh the VM's. Do i need to shut down any of the VMs?


After some changes i end up with Cache errors, see


I can figure everything else out, but no idea why i get those cache errors?


New Contributor

Hi Parik**bleep**,


Thanks for posting this nice article, I have been searching about hosting Moodle on azure for the past 24 hours, I am asked to host Moodle on azure and make it available on web and mobile as well. 


I came a cross on your post but I have zero experience with azure that is why I wanted to ask you what is the different between your way and hosting Moodle through Bitnami? what are the benefit of each way? could you please explain?


I am also asking you if you could help me to host my Moodle on azure because as I said I don't have experience I need a step by step guideline with details, would you please help?


Best Regards, 



New Contributor

@Parikshit Savjani quick question, where can we find the password for the dbadmin to login onto MySQL?

@Christian Araujo - it is auto-generated and you would can see it in input parameter as shown in screenshot below. When you copy the MoodleCommon in clipboard and search for dbLoginPassword, you will see the password. 





Click on dbtemplate 




Copy MoodleCommon to clipboard and paste it on notepad and search for dbLoginPassword to see the auto-generated password


There are a few questions about username and password here. Retrieval of this data is documented in Moodle/ at master · Azure/Moodle (

Occasional Visitor

How do we access the gluster nodes? What accounts/keys are they created with? The same question about the web VMSS nodes: Is there any way to log in to them to review the configuration?

Occasional Visitor

@Parikshit Savjani quick question, I am starting a new setup of Moodle Small to Mid-Size, almost 1k of concurrent users. If the concurrent user pass to 2k is it hard tak to pass to Large size deployment (with high availability)? it feasible?

Thank you for you advise

Occasional Visitor

I am a novice trying to use Moodle (bitnami Image) on Azure. Installation has gone through smooth, but not able to work or access Moodle to see what it is. Any documentation available for a novice like me?

Hi @Constant2000 - Could you please expand on what help you need and you are trying to achieve? To get help on how to use Moodle, you may want on Moodle forums. 

Version history
Last update:
‎Aug 09 2021 07:08 PM
Updated by: