Azure Template Spec and Logic App Integration

Cloud Journey
4 min readMar 7, 2021

--

Overview

Deployment at scale with consistency is part of cloud journey, so automation is inevitable.

In this article, we will explore Azure Template Spec and Logic App resource manager connector.

  • Expose ARM deployment via Rest API
  • Logic App is the runtime environment, so no need to maintain infrastructure for executing ARM template
  • ARM template and parameters are deployed to Template Spec for sharing and access control
  • CICD pipeline for integration test and deploying infrastructure code to Azure (Not covered in this article)
  • Standard ARM template and parameter files, does not require any customization and can be either integrated with logic app or executed directly

Lab

Create ARM Spec

In real project, you would check in ARM template and parameter files to code repo, and utilize CICD pipeline to create Azure Template Spec in Azure subscription.

In this exercise, you could create ARM Spec using AZ CLI, Powershell or through portal. You may refer to MS doc to get command and examples.

I guess template spec is designed for ARM template only, but in this exercise I use this service to host my ARM parameter file as well.

Template Spec with two versions
ARM Template
ARM Parameter File

Create Logic App Workflow

You will typically develop Logic App from UI, either Azure portal or IDE. For more detail, refer to MS doc.

In this exercise, there are one trigger and three actions in the logic app work flow.

JSON payload for the http request trigger.

{"template": "templateSpecs/vgw/versions/1.0","parameters": "templateSpecs/vgw/versions/1.0-params","subscriptionId": "xyz123","resourceGroup": "xyz456"}
HTTP Request Trigger

Logic App resource manager connector read a resource action.

Get Template JSON from Azure Template Spec
Get Parameter JSON from Azure Template Spec

Last task is to kick off ARM template. Template object and parameter object are derived from output from prior actions.

Execute ARM

Call the http request trigger URL from postman to execute logic app workflow.

Now let’s inspect the logic app run log. It successfully retrieved the template and parameter object from template spec, and deployed the ARM.

From resource group deployment blade, deployment logs are captured for the resource group deployment.

Why This Integration Matters

With ARM Spec and Logic App, we can build repeatable automation process to execute ARM template easily, sharing the ARM template and keep consistency.

Even though this article does not cover CICD pipeline, but it’s straight forward to use any CICD tool to deploy these infrastructure as code artifacts to Azure subscription. You can check in ARM template and parameter files to code repo just like any other artifacts, go through same review and approval procedure, use build pipeline to validate or what-if the ARM code, and use release pipeline to create or update Azure ARM spec.

Unlike Azure blueprints, this integration deploys exact standard ARM template with standard parameters file. As for blueprints, ARM template has to be wrapped with blueprints code in order to be executed through blueprints.

Even though we expect to run infrastructure code via automation, but in case automation fails and while we are in the process to improve automation, since we have 100% original ARM template and parameter files, we can easily execute them directly through multiple channels, Azureportal, CLI and Powershell.

Conclusion

It will be great Azure template spec has more support on ARM parameter file.

Another thought is about Logic App “create or update a template deployment” action from resource manager connector, currently whatif is not supported, Azure template spec ID is also not supported. Once these features are added, the deployment process will be further simplified.

References

Create & deploy template specs — Azure Resource Manager | Microsoft Docs

Template deployment what-if — Azure Resource Manager | Microsoft Docs

Quickstart — Create your first Logic Apps workflow — Azure portal — Azure Logic Apps | Microsoft Docs

Automate tasks and workflows with Visual Studio Code — Azure Logic Apps | Microsoft Docs

https://docs.microsoft.com/en-us/connectors/arm/#read-a-resource

--

--

Cloud Journey

All blogs are strictly personal and do not reflect the views of my employer. https://github.com/Ronnie-personal