Author: Sangram Rath
All components, i.e., Strapi & MySQL, run on a single VM; hence it is ideal for getting started, exploring Strapi, or a sandbox scenario.
What are Azure ARM templates?
Azure ARM templates are a way to implement infrastructure as code in Azure. Infrastructure as code's benefits includes deployment automation, consistent and repeatable infrastructure, and agility.
Deployment Specifications & Important Details
This guide uses an ARM (Azure Resource Manager) template to deploy the required Azure resources and a bash script to configure and install Strapi in it. You can do this with minimal user intervention.
The template creates the following required resources in its own new Resource Group:
- Azure Virtual Machine & a disk
- VNET & a Subnet
- vNIC, Network Security Group
Strapi installation steps run using a bash script after the VM provisioning. The script is part of the repository that contains the ARM template.
The ARM template (JSON file) and the bash script are available on the GitHub repo.
Default Values
Azure Defaults
Parameter | Value | Description |
---|---|---|
adminUsername | strapiadmin | Username for connecting (SSH) to the Azure VM |
adminPasswordOrKey | $tr@p!@12345 | Default password for the user |
Strapi Defaults
A Strapi app called blog is created with the following defaults.
Parameter | Value |
---|---|
NODE_ENV | development |
DB_HOST | localhost |
DB_PORT | 3306 |
DB_NAME | strapi_dev |
DB_USER | strapi |
DB_PASS | mysecurepassword |
JWT_SECRET | aSecretKey |
NOTE: This template has been deliberately created so that it requires the least possible inputs to get a working Strapi installation. Hence, many variables have been pre-defined as per minimum requirements. You can edit the ARM template if you wish to modify any variables, such as Azure VM size or password(s).
Running this Azure deployment as it is in Production is not recommended.
Pre-requisites
- An Azure account with an active Subscription
While it is not mandatory but a basic understanding of the following will help if you wish to customize this template or the script
- Basic knowledge of Microsoft Azure
- Basic knowledge of JSON
- Bash
- Git
Deploying the ARM template
Click the Deploy to Azure button below to load the template in Azure Portal. You may be prompted to sign in to Azure.
In the custom deployment page, click Create new and create a new Resource Group for this deployment.
Next, select your preferred Region and then click Review + create.
Ensure Validation passes , click Create to start the Azure resource deployment.
The deployment process will begin and take around 5-10 minutes.
NOTE: If the deployment fails, delete the resource group completely and restart the deployment. Do not use the Redeploy feature.-
Once the deployment is complete, click Outputs to retrieve the randomly generated Public DNS of the Azure VM.
You can also retrieve this & the Public IP address from the Overview section of the Azure VM.
You can now access the Strapi administration page at [DNS]:1337 or [PublicIP]:1337 and create the first administrator.
Modifying the default values
Azure infrastructure
You can modify the default values of the Azure infrastructure to your need. The following values could be changed (avoid changing other values, such as for networking and DNS, unless you are sure of the expected outcome):
- virtualMachineName
- adminUsername
- adminPasswordOrKey (we are using a password based login approach)
- vmSize (you will need to know the VM size SKUs)
After clicking Deploy to Azure, click Edit template.
Modify values as needed.
Click Save.
Continue with deployment.
Strapi installation
The installation uses some default values for database username, password, port, database name, etc. As mentioned earlier in the article, one can modify them after the installation if needed.
Refer to the documentation for instructions.
Security
- The installation does not expose the MySQL database running locally from outside.
- The installation does not use SSL/TLS by default.
Conclusion
This article demonstrates how to quickly bring up an Azure VM running Strapi using an ARM template or Infrastructure as Code approach.