azure-sdk-for-net icon indicating copy to clipboard operation
azure-sdk-for-net copied to clipboard

[QUERY] How do i access the network interface configuration of a machine in virtual scaleset ?

Open chkeita opened this issue 2 years ago • 6 comments

Library name and version

Azure.Management.Compute

Query/Question

I am trying to access this request from the api.

The closest i could get was with this query

var scalesetId = new ResourceIdentifier("...");
client.GetVirtualMachineScaleSetResource(scalesetId).GetVirtualMachineScaleSetVm("0").Value.Data.NetworkProfile;

but I can only get the the resourceId of the network interface from there and it looks like there is no ay to retrieve the actual interface data.

Am i missing something ?

Environment

.NET SDK (reflecting any global.json): Version: 6.0.302 Commit: c857713418

Runtime Environment: OS Name: Windows OS Version: 10.0.22000 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.302\

global.json file: Not found

Host: Version: 6.0.7 Architecture: x64 Commit: 0ec02c8c96

Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.27 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Download .NET: https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs: https://aka.ms/dotnet/runtimes-sdk-info

chkeita avatar Aug 02 '22 00:08 chkeita

Label prediction was below confidence level 0.6 for Model:ServiceLabels: 'Tables:0.17449068,Websites:0.06774416,App Services:0.05097205'

azure-sdk avatar Aug 02 '22 00:08 azure-sdk

Thank you for your feedback. Tagging and routing to the team member best able to assist.

jsquire avatar Aug 02 '22 12:08 jsquire

@chkeita you need to call client.GetVirtualMachineScaleSetResource(scalesetId).GetVirtualMachineScaleSetVm("0").Get() before you try to get the .Value, the GetVirtualMachineScaleSetVm does not actually made any request to Azure so the data is null.

xboxeer avatar Aug 12 '22 06:08 xboxeer

@xboxeer i dont have any issue accessing the result of that query. My problem is that i want to access the network configuration properties. The query i provided only gives me access to the resourceId of network interface. I am looking for a way to access the result of this request

chkeita avatar Aug 12 '22 13:08 chkeita

@chkeita the rest api you referred is a network RP api not a compute RP API, but due to some naming issue we have not implemented that API in SDK yet, we already have an issue looking into it: https://github.com/Azure/azure-sdk-for-net/issues/28185 Back to your question, if you try this code

 var vmss = this._client.GetDefaultSubscription().GetResourceGroup(resourceGroupName).Value.GetVirtualMachineScaleSet("elendil-test-vmss").Value;
var networkProfile = vmss.Data.VirtualMachineProfile.NetworkProfile;

you should be able to get the result as below, is this what you are looking for? image

xboxeer avatar Aug 23 '22 09:08 xboxeer

I'm facing the same issue. I need to get the private ip address of a vmss instance, as well as the mac address. What's pasted above doesn't provide that. Is there a workaround?

jallirs avatar Sep 22 '22 04:09 jallirs

@xboxeer, I'm also having the same issue. Even if you can get the NetworkProfile from VMSS VM, there's no public IP address that I can take from it. Even in the IPConfigurations that you expanded in the screenshot, there's no public IP address.

Does anyone know a proper way to retrieve the information?

s20leems avatar Mar 27 '23 18:03 s20leems

Hi All, this feature is available in the latest Network package, please have a try on that.

HarveyLink avatar Mar 25 '24 08:03 HarveyLink