Deploying an ARM template using Azure Monitor Workbooks

In a previous post, i talked about Azure Monitor Workbooks and how useful they are to visualize and monitor your environment interactively by querying multiple sources and displaying the results in different visualizations.

The sky is the limit to what you can build with Workbooks and in this post i will demonstrate one of the cool capabilities that allows to deploy an ARM template right from within the Workbook using Link actions.

Scenario

Let’s assume that you are interested in looking at the governance posture of your environment, more specifically to your tagging compliance. You would like to be able to see all of the untagged Virtual machines and be able to take action by deploying a certain tag to them. Let’s start creating a Workbook that will do just that 🚀.

  1. First thing is to add some parameters to make our Workbook more usable.
    • Add a Subscription parameter. Subscription parameter
  • Add a Resource group parameter. Resource group parameter

Parameters view

  1. We also need to add parameters for the tags that we will deploy. Those will be text parameters.

Tags parameters

  1. Next, we need to add a query to list all untagged Virtual machines. We will use Azure Resource Graph to list them.

Untagged VMs query

Untagged VMs query view

💡 You can see that i have added a new column named DeployTag which i will use later for the ARM template.

  1. Now, let’s go to Column Settings where all the magic happens.
  2. Change the Column renderer of the “DeployTag” column to Link, choose the view to be ARM Deployment and type in a label for this link Deploy Tag(this will be the text displayed for each Virtual machine).

Column settings - ARM Deployment

  1. Then we need to configure the ARM deployment settings:
    • Since this is an ARM deployment, we need to get the Resource group Id. It’s already exposed in the Virutal machines’ query in the column resourceGroupID.
    • Set the URI for the ARM template to a static value and provide it’s URI (in my case I have it hosted on GitHub).
    • To refresh the view with the parameters of the ARM template, press on the arrow button to initialize the view. You can see that the preview is showing the parameters we have in the ARM template.

ARM Deployment initialize

  • Select where the parameters will come from, in our case the Virtual machine name is in the previous query and the tags are parameters.

Column settings - ARM Deployment URI

  • Finally, go to the UX Settings tab to provide descriptive text when you start the deployment process.

    Column settings - UX Settings

    Column settings - UX Settings button

  • Save and Close.

Testing the Workbook

  • If we click Done Editing and view our Workbook, we can see that we have one Virtual machine that is untagged and we can see the Deploy Tag link in the query.

Workbook final view

  • On clicking this link, we can see the context menu with information on what will this action deploy as we specified in the UX Settings

Workbook deploy menu

  • The deployment process starts and in a couple of seconds, we can see that the tag is successfully deployed to the Virtual machine.

VM with tag deployed

VM with tag deployed not showing in the query

Share on:

You May Also Like