A friend of mine recently started working with Azure and loved it once he got the hang of it. I encouraged him to start using PowerShell to automate various Azure operations but it didn’t quite stick with him on the first try. He started automating Azure operations using the Azure CLI and while it’s not a bad tool, it’s quite lacking in features compared to PowerShell and I’m pretty sure that it will not be maintained much longer since Microsoft open sourced PowerShell and gave the Linux / Mac community a taste. The funny part of this story is that he’s a Windows user, uses Windows 10 and yet he’s still using Azure CLI.

Where am I going with this? While giving him some tips on how to deploy some production / staging environments in Azure, I saw how he was automating resource creation in Azure using the CLI. He basically created a golden image in a storage account and with 35 lines of Azure CLI code, he was provisioning the environments. That made me cringe and motivated me to teach him how to do it using ARM templates and custom scripts.

Long story short, I taught him the basics of ARM Templates and to give him a nudge in the right direction, I created an ARM Template that served his needs and to share with the community, I have attached it in this blog post as well 🙂

In a nutshell, the ARM Template creates a storage account, a load balancer, a public IP, a specific number of CentOS 7.2 Virtual Machines with one data disk per instance and uses a custom bash script that configures the VMs. The template also configures the load balancer to probe ports 80 and 443 and set NAT rules for SSH on each VM instance.

The template has one simple requirement. Your custom script has to be in a storage account.

You can obtain the FileUri using the Azure Portal or Storage Explorer and the CommandToExecute should contain sh filename.sh and additional parameters if required.

The bash script attached in this post does a couple of things:

1. Disables SELINUX
2. Adds the latest EPEL (Extra Packages for Enterprise Linux) for version 7.
3. Installs NGINX, PHP 5.6 and some PHP 5.6 Packages.
4. Installs oAuth
5. Does some required configuration for NGINX to work
6. Configures the data disk
7. Some performance oriented settings for the web server.

One thing to note: Do not try to do a YUM upgrade / update. It will break the process.

Now without further ado, here’s the ARM Template and the bash script.

Privacy Preference Center

    Pin It on Pinterest