I want to list all VMs in a Scale Set and print the VM name, and private and public IP using the C# management SDK. Sofar I have the following code:
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Compute;
var armClient = new ArmClient(new DefaultAzureCredential());
var scaleSet = armClient.GetVirtualMachineScaleSetResource("/long/id");
Console.WriteLine("vms:");
await foreach (var vm in ss.GetVirtualMachineScaleSetVms().GetAllAsync())
{
Console.WriteLine($" vm: {vm.Id.Name}");
}
The above code works and prints -- as expected -- the list of vms in my scaleset:
vms:
vm: fleet-a_90f4de84
vm: fleet-a_c439ee3c
However, I cannot figure out how to get the network information from here.
I expected to find it in vm.Data.NetworkProfile
or vm.Data.NetworkInterfaceConfigurations[].
but even though vm.HasData
is true
, vm.Data
has all fields set to null
(and vm.Data.NetworkInterfaceConfigurations[]
is empty):