https://pulumi.com logo
#dotnet
Title
# dotnet
t

thankful-alarm-12978

12/16/2019, 1:30 PM
Hello, how do I look up the resource ID of a virtual network? For example, a resource with the name "vnet-mei-dev-01" is a pre-existing virtual network that we are not creating via Pulumi. We would get "vnet-mei-dev-01" from the stack. What's is the best way of looking this resource up in Pulumi so that we can use the fully qualified ID for the remoteVirtualNetworkId property when creating an A_zure_.network.VirtualNetworkPeering. Example of the fully qualified ID: "/subscriptions/52e39ec9-0204-44ae-8abe-2401582a288d/resourceGroups/rg-mei-dev-01/providers/Microsoft.Network/virtualNetworks/vnet-mei-dev-01". Thanks
t

tall-librarian-49374

12/16/2019, 1:44 PM
Try something like
Copy code
var vnet = await Pulumi.Azure.Network.Invokes.GetVirtualNetwork(new GetVirtualNetworkArgs
{
    ResourceGroupName = "rg-mei-dev-01",
    Name = "vnet-mei-dev-01",
});

var id = vnet.Id;
t

thankful-alarm-12978

12/16/2019, 1:47 PM
Thanks Mikhail..will give it a go. Appreciate the quick response.