This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.
This example scenario is a guidance on how to deploy a highly available and scalable Wordpress on Azure using Application Gateway that uses a Virtual Machine Scale Set for backend servers and all deployed into three availability zones to ensure availability and scalability. The Application Gateway will ensure the usage of session affinity, a requirement for Wordpress.
Those backend servers will be hosting a Wordpress configured over a NFS Share on Azure Files service and connected to an Azure Database for MySQL service.
To connect the VMs to the MySQL and NFS Share services, two Azure Private Endpoints will be configured to connect them privately and securely.
Architecture
Prerequisites
- Use the Bash environment in Azure Cloud Shell.
-
If you prefer, install the Azure CLI to run CLI reference commands.
-
This tutorial requires version 2.0.4 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
Define Variables
Create Resource Group
Create a VNET
Please note that the subnet created here will be the dedicated subnet to Application Gateway
Create a Backend Subnet
Create a Public IP for the Application Gateway
Update the backend subnet
Is required to disable network policies for private endpoints
Create the Application Gateway
Create FileStorage Account
Create an NFS share
Create a Private Endpoint to use with Azure FileStorage
Configure the private DNS zone for Azure FileStorage
Disable secure transfer setting on Storage Account
The secure transfer setting isn't supported on NFS protocol, so it's required to disable it:
Register your subscription to use the NFS 4.1 protocol
As NFS is a preview feature at this time, you need register your subscription to be able to use.
Create MySQL
Create a Private Endpoint to use with Azure Database for MySQL
Configure the Private DNS Zone for Azure Database for MySQL
Create a firewall rule on Azure Database for MySQL
This will allow connect on Azure Database from AZ CLI to create the database
Create a database with a non-admin user in Azure Database for MySQL
Remove the firewall rule previously created to create the database from AZ CLI.
As the access from VMs to the database will use the private endpoint connection, we don't need it anymore. Was required just to be able to connet to MySQL from AZ CLI and create the Wordpress database.
Generate cloud-init
At this step the cloud-init will be generated to create the configuration inside the VMs and install required packages.
Create a Virtual Machine Scale Set
Get the Application Gateway Public IP
Finish the Wordpress installation
Please note the complete setup of the VMs configuration can take up to 5 minutes. So if you try access and got the "Welcome to nginx!" message, it means that the setup wasn't finished yet. So take another cup of coffee before try access again =D
In your web browser, navigate to the Application Gateway Public IP and complete the Wordpress installation through the web interface:
Select the language you would like to use:
Next, you will come to the main setup page.
Select a name for your WordPress site and choose a username. It is recommended to choose something unique and avoid common usernames like “admin” for security purposes. A strong password is generated automatically. Save this password or select an alternative strong password.
Enter your email address and select whether you want to discourage search engines from indexing your site:
When you click ahead, you will be taken to a page that prompts you to log in:
Once you log in, you will be taken to the WordPress administration dashboard:
Change manually the capacity of a scale set
When you created a Virtual Machine Scale, three VM instances were deployed by the parameter --instance-count 3. To increase or decrease the number of VM instances in your existing scale set, you can manually change the capacity. The scale set creates or removes the required number of VM instances then will distribute the traffic.
To manually increase or decrease the number of VM instances in the scale set, use az vmss scale. The following example sets the number of VM instances in your scale set to 5: