@Dnyaneshwar Surywanshi Apologies for the delayed response.
I tried to work backwards to get NIC details from the VM, then the Subnet to which the NIC was bound to and then the VNet to which the subnet belonged.
var vm = azure.VirtualMachines.GetById("/subscriptions/**-**-**-**/resourceGroups/Networking-Lab/providers/Microsoft.Compute/virtualMachines/VM1");
var primaryNetworkInterface = vm.GetPrimaryNetworkInterface();
var subnetId = azure.NetworkInterfaces.GetById(primaryNetworkInterface.Id).Inner.IpConfigurations.FirstOrDefault().Subnet.Id;
var vNet = azure.Networks.List().Where(n => n.Inner.Subnets.Select(sn => string.Equals(sn.Id, subnetId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault()).FirstOrDefault();
Console.Write($" VirtualMachine: {vm.Name} \n NetworkInterface: {primaryNetworkInterface.Name} \n VirtualNetwork: {vNet.Name} \n Subnet: {ResourceUtils.NameFromResourceId(subnetId)}");
Here is the output
Please let me know if you face any issues.
----------
If an answer is helpful, please "Accept answer" or "Up-Vote" for the same which might be beneficial to other community members reading this thread.