Deploy a sample Tomcat Application on an Azure Virtual Machine Scale Set
Option 1 for Ubuntu management VM
- Create a Terraform Ubuntu virtual machine with managed identities using a marketplace template here
Option 2 for CentOS management VM
- Create a Terraform Centos virtual machine with managed identities.
- Source code - AzureTerraformTemplates/POCtoPattern/MgmtVmMI/
- Populate variables.tf and run terraform apply within folder
Setup Steps
- Contributor permission helps MSI on VM to use Terraform to create resources outside the VM resource group. You can easily achieve this action by running a script once inside the Terraform Linux vm. ~/tfEnv.sh
- The VM has a Terraform remote state back end. To enable it on your Terraform deployment, copy the remoteState.tf file from tfTemplate directory to the root of the Terraform scripts. cp ~/tfTemplate/remoteState.tf .
- Install the Packer precompiled binary on the Terraform VM download
- Clone the Github repository to the Terraform VM download
- Series of Labs for Terraform on Azure here
- Create a customized Ubuntu managed image with Tomcat installed
- Store the image in a shared image gallery
- Create a Key Vault enabled for disk encryption and a Key
- Deploy a Virtual machine scale set
- Enable service endpoint for Key Vault.
- Update key vault access policy to allow scale set subnet.
- Enable disk encryption extension and associate with key
- Access Tomcat webpage
- Create a customized Ubuntu managed image with Tomcat installed
- Create a Key Vault enabled for disk encryption and a Key
- Deploy a Virtual machine scale set
- Access Tomcat webpage
Start Here by reading the following document on how to build an Azure build pipeline POCtoPattern/Azure Build pipeline - Customized image in Shared Image Gallery.docx
-
Create an Azure DevOps project
-
Import the Packer json into Azure repot
-
Install the hosted build agent into the Terraform linux vm
-
Setup a build pipeline with tasks using the replace tokens module to populate environment variables into the json file.
- Documentation is in Azure Build pipeline - Customized image in Shared Image Gallery.docx
-
The output is a customized managed image.
-
Note the resource group and name of the final managed image.
1.Login to Terraform vm with a managed identity where github repository was cloned and run the following commands.
-
Change to the Source directory for key vault which is AzureTerraformTemplates/POCtoPattern/KeyVaultDiskEncryption/
export ARM_USE_MSI=true
Terraform init
Terraform apply -out output
Create a release pipeline using the shared image gallery build artificat created in
AzureTerraformTemplates/POCtoPattern/Azure Release pipeline - Deply Scale Set using customized tomcat image in SIG.docx