azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

NetworkProfile output from Get-AzureRMVM is not directly useful to get NetworkInterface

Open MattAllison opened this issue 9 years ago • 4 comments

Cmdlet(s)

Get-AzrueRMVM

PowerShell Version

PSVersion 5.1.15063.296

Module Version

3.3.1 AzureRM.Compute

OS Version

10.0.15063.296

Description

The "NetworkProfile" prooperty from Get-AzureRMVM is too difficult to use.

The output is only the a collection of items containing the ResourceID of the Network Interface. This output cannot be directly consumed by other functions such as Get-AzureRMNetworkInterface as that function does not support a ResourceId parameter.

Using the output requires (obviously) either parsing the ResourceId to find the ResourceGroup and Name values or and additional invocation of Find-AzureRMResource.

Neither of these steps should be necessary - especially when the main use is likely to simply be to find the IP address used by the interface.

Debug Output

N/A

Script/Steps for Reproduction

$vm = Get-AzureRMVM -ResourceGroupName myRGName -Name myVMName $vm.NetworkProfile

MattAllison avatar Aug 28 '17 16:08 MattAllison

@DeepakRajendranMsft Hey Deepak, it looks like the request is to add a parameter set to the Get-AzureRmNetworkInterface cmdlet that accepts a ResourceId so they can pipe the result of (Get-AzureRmVM -Name $VM -ResourceGroupName $RG).NetworkProfile to the cmdlet.

cormacpayne avatar Sep 01 '17 06:09 cormacpayne

@praries880 would you mind handling this issue when you have time? Let me know if you'd like me to reassign this to someone else.

cormacpayne avatar Jul 05 '18 23:07 cormacpayne

Core issue here is not in Get-AzureRmVm, thr issue is in the Get-AzureRMNetworkInterface cmdlet. Get-AzureRMNetworkInterface should have a param set that takesn in a resource Id and returns the network interface for the provided resource ID.

@MikhailTryakhov can you take a look?

The API Spec itself does not seem to support getting a network interface using a resource ID. The cmdlet however could try and parse the passed in resource Id to get the RG name and resource name to then call the get operation with RG name and resource name.

praries880 avatar Jul 25 '18 18:07 praries880

Added ResourceId parameter to Get-NIC to allow getting it using Id only

EvgenyAgafonchikov avatar Feb 04 '19 06:02 EvgenyAgafonchikov