Member-only story
Troubleshooting VM ID Retrieval in Azure DevOps Pipeline: A Guide
Azure DevOps pipelines are a powerful tool for automating workflows, including setting up and managing Azure DevTest Labs environments. However, during pipeline runs, there are often scenarios where retrieving specific environment information — such as the VM ID — can be critical for logging, debugging, or further automation steps. This article focuses on troubleshooting and addressing a common issue encountered when attempting to display a VM ID in an Azure DevOps pipeline.
The Issue
During a pipeline run, you may encounter a log output like this:
Starting: Display VM ID
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.244.3
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
echo "The VM ID is: $(vm.vmId)"
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/eae479d6-89c9-4a99-8806-8136d85b0119.sh…