Use this data source to access information about an existing Virtual Machine.
provider "azurerm" {
features {}
}
data "azurerm_virtual_machine" "example" {
name = "production"
resource_group_name = "networking"
}
output "virtual_machine_id" {
value = data.azurerm_virtual_machine.example.id
}
name
- Specifies the name of the Virtual Machine.
resource_group_name
- Specifies the name of the resource group the Virtual Machine is located in.
id
- The ID of the Virtual Machine.
identity
- A identity
block as defined below.
private_ip_address
- The Primary Private IP Address assigned to this Virtual Machine.
private_ip_addresses
- A list of Private IP Addresses assigned to this Virtual Machine.
public_ip_address
- The Primary Public IP Address assigned to this Virtual Machine.
public_ip_addresses
- A list of the Public IP Addresses assigned to this Virtual Machine.
power_state
- The power state of the virtual machine.
An identity
block exports the following:
identity_ids
- The list of User Managed Identity IDs which are assigned to the Virtual Machine.
principal_id
- The ID of the System Managed Service Principal assigned to the Virtual Machine.
tenant_id
- The ID of the Tenant of the System Managed Service Principal assigned to the Virtual Machine.
type
- The identity type of the Managed Identity assigned to the Virtual Machine.
The timeouts
block allows you to specify timeouts for certain actions:
read
- (Defaults to 5 minutes) Used when retrieving the Virtual Machine.