简体   繁体   English

如何获取 azure VM 的 azure VMUUID?

[英]How to get the azure VMUUID of azure VM?

I am creating an ARM template for the Azure Log Analytics workspace.it has some queries which use azure VM's VMUUID.我正在为 Azure Log Analytics 工作区创建一个 ARM 模板。它有一些使用 azure VM 的 VMUUID 的查询。 Is there is any way to fetch the azure VM's VMUUID inside the ARM template or any other way to fetch azure VMUUID?有什么方法可以在 ARM 模板中获取 azure VM 的 VMUUID 或任何其他方法来获取 azure VMUUID? ARM Template I just need to get the values of VMUUID of all VM's in that subscription. ARM 模板我只需要获取该订阅中所有 VM 的 VMUUID 的值。

You can also get this information programmatically from the Azure Instance Metadata Service (IMDS).您还可以通过 Azure 实例元数据服务 (IMDS) 以编程方式获取此信息。 It provides information about currently running virtual machine instances.它提供有关当前运行的虚拟机实例的信息。 You can use IMDS to manage and configure your virtual machines.您可以使用 IMDS 来管理和配置您的虚拟机。 This information includes the SKU, storage, network configurations, and upcoming maintenance events.此信息包括 SKU、存储、网络配置和即将发生的维护事件。 For a complete list of the data available, see the Endpoint Categories Summary .有关可用数据的完整列表,请参阅端点类别摘要

IMDS is a REST API that's available at a well-known, non-routable IP address 169.254.169.254 . IMDS 是 REST API,可在众所周知的、不可路由的 IP 地址169.254.169.254处获得。 You can only access it from within the VM.您只能从 VM 中访问它。 Communication between the VM and IMDS never leaves the host. VM 和 IMDS 之间的通信永远不会离开主机。

https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service

You could easily find it in the Azure Resource Explorer .您可以在Azure 资源浏览器中轻松找到它。

//One more extra reference: What is Azure Resource Explorer? //另外一个参考: 什么是Azure Resource Explorer?

Just navigate to the Microsoft.Compute => virtualMachines view:只需导航到 Microsoft.Compute => virtualMachines 视图:

在此处输入图像描述

There is one more way to find it, but for me seems more complicated as you need to connect to the VM: https://azure.microsoft.com/en-us/blog/accessing-and-using-azure-vm-unique-id/还有另一种方法可以找到它,但对我来说似乎更复杂,因为您需要连接到 VM: https://azure.microsoft.com/en-us/blog/accessing-and-using-azure-vm-唯一身份/

Update:更新:

Below simple PowerShell script returns list of all VMUUIDs in the specified subscription:下面简单的 PowerShell 脚本返回指定订阅中所有 VMUUID 的列表:

Get-AzSubscription
Select-AzSubscription -SubscriptionId "Olga's Subscription"
$GetVM = Get-AzVM
Foreach ($vm in $GetVM)
{
$vmId =""
$vmId = $vm.vmid
$vmIdList +=$vmId + "`r`n"
}
Write-Output $vmIdList

Please let me know if above answers your question.如果以上回答了您的问题,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM