It sounds like you are wanting to run the command sudo WIZ_API_CLIENT_ID=
across a list of Azure Linux VMs. Please let me know if I am understanding this correctly.
One method would be to utilize Run Command for Azure to execute the command across a list of VMs. Assuming you have a file with the VM names you could use this script to fetch the Resource Group and run the command.
#!/bin/bash
# Path to the file containing VM names
vm_file="vm_names.txt"
# Command to execute on each VM
command_to_run="your-command-here"
# Loop through each VM name in the file
while IFS= read -r vm_name; do
# Get the resource group of the VM
resource_group=$(az vm show --name "$vm_name" --query "resourceGroup" -o tsv)
# Execute the command on the VM
az vm run-command invoke --resource-group "$resource_group" --name "$vm_name" --command-id RunShellScript --scripts "$command_to_run"
done < "$vm_file"
Hope this helps! Please let me know if you have any questions.
If you still have questions, please let us know in the "comments" and we would be happy to help you. Comment is the fastest way of notifying the experts.
If the answer has been helpful, we appreciate hearing from you and would love to help others who may have the same question. Accepting answers helps increase visibility of this question for other members of the Microsoft Q&A community.
Thank you for helping to improve Microsoft Q&A!