I am creating an ARM template for the Azure Log Analytics workspace.it has some queries which use azure VM's VMUUID.Is there is any way to fetch the azure VM's VMUUID in ARM template or any other ways to fetch azure VMUUID?
I am creating an ARM template for the Azure Log Analytics workspace.it has some queries which use azure VM's VMUUID.Is there is any way to fetch the azure VM's VMUUID in ARM template or any other ways to fetch azure VMUUID?
According to a blog post from 2014 it should be possible to get the VMUUID for both Linux and Windows Hosts with some pretty straightforward scripts. Like this one (for windows):
These scripts could be run on the VMs themselves, or by using the "Run command" option offered from the VM's blade in Azure.
You can also deploy the script to run via the VM's ARM template, by using a VM extension. This way you can have the VMUUID ready right after the deployment completes. An example of how an extension could look in the template:
Keep in mind that the script (the first codeblock) itself would need to be accessible for Azure Resource Manager through an URI. You could provide this either through a public GitHub repo (probably easiest) or through Azure Storage account and an SAS token.
Now, for getting the output out directly, I'm not so sure. One option is to append the script, and have it write to a file or location you can access later. Another option, which I haven't tried myself yet, is to get the output through the template itself as described in this sample: Azure Quickstart Template. I probably will spin an RG up for myself later to take a look, but feel free to tell me if you decide to check that route out, and how it went :)
This was longer than I expected to write, and might not be that clear, but I at least hope it can point you in the right direction!
Thanks, Emil