Azure, Open Source and ...

Terraform and Azure Better Together! (Deploying Azure Function via Terraform)

You simply gotta love Terraform for obvious reasons but now specially for the awesome Azure integration available to all of us!

As announced yesterday here we now have access to brand new offering Terraform solution in the Azure Marketplace. This solution will enable teams to use shared identity, using Managed Service Identity (MSI), and shared state using Azure Storage. These features will allow you to use a consistent hosted instance of Terraform for DevOps Automation and production scenarios.

So I decided to give this a try and deploy a Hello World Azure Function as I am a fanboy of Serverless so why not!

As explained in the link above, the first step was to deploy the already configure box with all the goodies including the Azure CLI, Terraform bit and get it going!

Next was to SSH to the box (Don’t forget to enable Azure Security Center JIT VM Access!) and run the script already provided to set up the shared identity:

Now that the shared identity is setup we needed to run Terraform Init:

For the configuration file, I used the sample from Terraform site  and modified for this effort and saved it as azfunc.tf:

Running Terraform Plan did the validation and the last step was to run Terraform Apply to get this deployment going:

And before you know it my Azure Function was ready to rock and roll!

Make sure to give this a try if you have not and join the rest of us to adopt Terraform!