1. Packages
  2. Azure Classic
  3. API Docs
  4. compute
  5. getVirtualMachine

We recommend using Azure Native.

Azure v6.10.0 published on Tuesday, Nov 19, 2024 by Pulumi

azure.compute.getVirtualMachine

Explore with Pulumi AI

azure logo

We recommend using Azure Native.

Azure v6.10.0 published on Tuesday, Nov 19, 2024 by Pulumi

    Use this data source to access information about an existing Virtual Machine.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const example = azure.compute.getVirtualMachine({
        name: "production",
        resourceGroupName: "networking",
    });
    export const virtualMachineId = example.then(example => example.id);
    
    import pulumi
    import pulumi_azure as azure
    
    example = azure.compute.get_virtual_machine(name="production",
        resource_group_name="networking")
    pulumi.export("virtualMachineId", example.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/compute"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := compute.LookupVirtualMachine(ctx, &compute.LookupVirtualMachineArgs{
    			Name:              "production",
    			ResourceGroupName: "networking",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("virtualMachineId", example.Id)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Azure = Pulumi.Azure;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Azure.Compute.GetVirtualMachine.Invoke(new()
        {
            Name = "production",
            ResourceGroupName = "networking",
        });
    
        return new Dictionary<string, object?>
        {
            ["virtualMachineId"] = example.Apply(getVirtualMachineResult => getVirtualMachineResult.Id),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.azure.compute.ComputeFunctions;
    import com.pulumi.azure.compute.inputs.GetVirtualMachineArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var example = ComputeFunctions.getVirtualMachine(GetVirtualMachineArgs.builder()
                .name("production")
                .resourceGroupName("networking")
                .build());
    
            ctx.export("virtualMachineId", example.applyValue(getVirtualMachineResult -> getVirtualMachineResult.id()));
        }
    }
    
    variables:
      example:
        fn::invoke:
          Function: azure:compute:getVirtualMachine
          Arguments:
            name: production
            resourceGroupName: networking
    outputs:
      virtualMachineId: ${example.id}
    

    Using getVirtualMachine

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getVirtualMachine(args: GetVirtualMachineArgs, opts?: InvokeOptions): Promise<GetVirtualMachineResult>
    function getVirtualMachineOutput(args: GetVirtualMachineOutputArgs, opts?: InvokeOptions): Output<GetVirtualMachineResult>
    def get_virtual_machine(name: Optional[str] = None,
                            resource_group_name: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetVirtualMachineResult
    def get_virtual_machine_output(name: Optional[pulumi.Input[str]] = None,
                            resource_group_name: Optional[pulumi.Input[str]] = None,
                            opts: Optional[InvokeOptions] = None) -> Output[GetVirtualMachineResult]
    func LookupVirtualMachine(ctx *Context, args *LookupVirtualMachineArgs, opts ...InvokeOption) (*LookupVirtualMachineResult, error)
    func LookupVirtualMachineOutput(ctx *Context, args *LookupVirtualMachineOutputArgs, opts ...InvokeOption) LookupVirtualMachineResultOutput

    > Note: This function is named LookupVirtualMachine in the Go SDK.

    public static class GetVirtualMachine 
    {
        public static Task<GetVirtualMachineResult> InvokeAsync(GetVirtualMachineArgs args, InvokeOptions? opts = null)
        public static Output<GetVirtualMachineResult> Invoke(GetVirtualMachineInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetVirtualMachineResult> getVirtualMachine(GetVirtualMachineArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: azure:compute/getVirtualMachine:getVirtualMachine
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    Specifies the name of the Virtual Machine.
    ResourceGroupName string
    Specifies the name of the resource group the Virtual Machine is located in.
    Name string
    Specifies the name of the Virtual Machine.
    ResourceGroupName string
    Specifies the name of the resource group the Virtual Machine is located in.
    name String
    Specifies the name of the Virtual Machine.
    resourceGroupName String
    Specifies the name of the resource group the Virtual Machine is located in.
    name string
    Specifies the name of the Virtual Machine.
    resourceGroupName string
    Specifies the name of the resource group the Virtual Machine is located in.
    name str
    Specifies the name of the Virtual Machine.
    resource_group_name str
    Specifies the name of the resource group the Virtual Machine is located in.
    name String
    Specifies the name of the Virtual Machine.
    resourceGroupName String
    Specifies the name of the resource group the Virtual Machine is located in.

    getVirtualMachine Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Identities List<GetVirtualMachineIdentity>
    A identity block as defined below.
    Location string
    Name string
    PowerState string
    The power state of the virtual machine.
    PrivateIpAddress string
    The Primary Private IP Address assigned to this Virtual Machine.
    PrivateIpAddresses List<string>
    A list of Private IP Addresses assigned to this Virtual Machine.
    PublicIpAddress string
    The Primary Public IP Address assigned to this Virtual Machine.
    PublicIpAddresses List<string>
    A list of the Public IP Addresses assigned to this Virtual Machine.
    ResourceGroupName string
    Id string
    The provider-assigned unique ID for this managed resource.
    Identities []GetVirtualMachineIdentity
    A identity block as defined below.
    Location string
    Name string
    PowerState string
    The power state of the virtual machine.
    PrivateIpAddress string
    The Primary Private IP Address assigned to this Virtual Machine.
    PrivateIpAddresses []string
    A list of Private IP Addresses assigned to this Virtual Machine.
    PublicIpAddress string
    The Primary Public IP Address assigned to this Virtual Machine.
    PublicIpAddresses []string
    A list of the Public IP Addresses assigned to this Virtual Machine.
    ResourceGroupName string
    id String
    The provider-assigned unique ID for this managed resource.
    identities List<GetVirtualMachineIdentity>
    A identity block as defined below.
    location String
    name String
    powerState String
    The power state of the virtual machine.
    privateIpAddress String
    The Primary Private IP Address assigned to this Virtual Machine.
    privateIpAddresses List<String>
    A list of Private IP Addresses assigned to this Virtual Machine.
    publicIpAddress String
    The Primary Public IP Address assigned to this Virtual Machine.
    publicIpAddresses List<String>
    A list of the Public IP Addresses assigned to this Virtual Machine.
    resourceGroupName String
    id string
    The provider-assigned unique ID for this managed resource.
    identities GetVirtualMachineIdentity[]
    A identity block as defined below.
    location string
    name string
    powerState string
    The power state of the virtual machine.
    privateIpAddress string
    The Primary Private IP Address assigned to this Virtual Machine.
    privateIpAddresses string[]
    A list of Private IP Addresses assigned to this Virtual Machine.
    publicIpAddress string
    The Primary Public IP Address assigned to this Virtual Machine.
    publicIpAddresses string[]
    A list of the Public IP Addresses assigned to this Virtual Machine.
    resourceGroupName string
    id str
    The provider-assigned unique ID for this managed resource.
    identities Sequence[GetVirtualMachineIdentity]
    A identity block as defined below.
    location str
    name str
    power_state str
    The power state of the virtual machine.
    private_ip_address str
    The Primary Private IP Address assigned to this Virtual Machine.
    private_ip_addresses Sequence[str]
    A list of Private IP Addresses assigned to this Virtual Machine.
    public_ip_address str
    The Primary Public IP Address assigned to this Virtual Machine.
    public_ip_addresses Sequence[str]
    A list of the Public IP Addresses assigned to this Virtual Machine.
    resource_group_name str
    id String
    The provider-assigned unique ID for this managed resource.
    identities List<Property Map>
    A identity block as defined below.
    location String
    name String
    powerState String
    The power state of the virtual machine.
    privateIpAddress String
    The Primary Private IP Address assigned to this Virtual Machine.
    privateIpAddresses List<String>
    A list of Private IP Addresses assigned to this Virtual Machine.
    publicIpAddress String
    The Primary Public IP Address assigned to this Virtual Machine.
    publicIpAddresses List<String>
    A list of the Public IP Addresses assigned to this Virtual Machine.
    resourceGroupName String

    Supporting Types

    GetVirtualMachineIdentity

    IdentityIds List<string>
    The list of User Managed Identity IDs which are assigned to the Virtual Machine.
    PrincipalId string
    The ID of the System Managed Service Principal assigned to the Virtual Machine.
    TenantId string
    The ID of the Tenant of the System Managed Service Principal assigned to the Virtual Machine.
    Type string
    The identity type of the Managed Identity assigned to the Virtual Machine.
    IdentityIds []string
    The list of User Managed Identity IDs which are assigned to the Virtual Machine.
    PrincipalId string
    The ID of the System Managed Service Principal assigned to the Virtual Machine.
    TenantId string
    The ID of the Tenant of the System Managed Service Principal assigned to the Virtual Machine.
    Type string
    The identity type of the Managed Identity assigned to the Virtual Machine.
    identityIds List<String>
    The list of User Managed Identity IDs which are assigned to the Virtual Machine.
    principalId String
    The ID of the System Managed Service Principal assigned to the Virtual Machine.
    tenantId String
    The ID of the Tenant of the System Managed Service Principal assigned to the Virtual Machine.
    type String
    The identity type of the Managed Identity assigned to the Virtual Machine.
    identityIds string[]
    The list of User Managed Identity IDs which are assigned to the Virtual Machine.
    principalId string
    The ID of the System Managed Service Principal assigned to the Virtual Machine.
    tenantId string
    The ID of the Tenant of the System Managed Service Principal assigned to the Virtual Machine.
    type string
    The identity type of the Managed Identity assigned to the Virtual Machine.
    identity_ids Sequence[str]
    The list of User Managed Identity IDs which are assigned to the Virtual Machine.
    principal_id str
    The ID of the System Managed Service Principal assigned to the Virtual Machine.
    tenant_id str
    The ID of the Tenant of the System Managed Service Principal assigned to the Virtual Machine.
    type str
    The identity type of the Managed Identity assigned to the Virtual Machine.
    identityIds List<String>
    The list of User Managed Identity IDs which are assigned to the Virtual Machine.
    principalId String
    The ID of the System Managed Service Principal assigned to the Virtual Machine.
    tenantId String
    The ID of the Tenant of the System Managed Service Principal assigned to the Virtual Machine.
    type String
    The identity type of the Managed Identity assigned to the Virtual Machine.

    Package Details

    Repository
    Azure Classic pulumi/pulumi-azure
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azurerm Terraform Provider.
    azure logo

    We recommend using Azure Native.

    Azure v6.10.0 published on Tuesday, Nov 19, 2024 by Pulumi