Basic terraform example for Azure VM Scale Sets with Azure Front Door to understand terraform properties for multi-region application.
Scenario: We have two VMs as Azure VM Scale Sets instances for our business application. Azure Front Door have a backend pool that contains these VMs. If the VM instance in one region fails, Azure Front Door handle the requests with other region. This is just a simple terraform example so some additional commands are needed to be executed in the scale set instance to do some test. In real-life scenario, pre-build VM Images with applications should be used.
- Check terraform.tfvars file, update required Azure Service Principal values and VM info.
- Run following terraform commands in order
terraform init
terraform plan
terraform apply -auto-approve
There are two VMs as jump-box per region to connect VM Scale Sets instance. From that jump-boxes, we need to RDP to VM Scale Sets instances.
In this example, IIS's default page mocks an application. So, first IIS should be installed in VM instance.
- Get scale set instances' Windows features
Get-WindowsFeature | where{$_.InstallState -eq "Installed"}
- Install Web-Server(a.k.a IIS) windows feature to VM Scale Set instance to do some test
Install-WindowsFeature -Name Web-Server -IncludeAllSubFeature -IncludeManagementTools
- Check localhost
Invoke-WebRequest -Uri 127.0.0.1 -UseBasicParsing
- Check connectivity in scale set instance
Invoke-WebRequest -Uri https://www.google.com -UseBasicParsing
- Change default IIS Page's content; this is for to observe application in other region
Set-Content -Path C:\inetpub\wwwroot\iistart.htm -Value "Hello World - Region 01/02"
- Try stoping and restarting IIS in VM Scale Sets instance per regions and observe the output.
iisreset /stop
iisreset /start