Azure / Azure/azure-powershell

Get-AzDelegation returns an error when null

Open
#13,180 5 comments 0 reactions 0 assignees View on GitHub
act-quality-productivity-squad customer-reported Network - Virtual Network question Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

```
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Get-AzDelegation 3.3.0 Az.Network
```

When I run the command as below an error is returned (the delegation does not exist) :-
```
Get-AzDelegation -Name nmeFunction -Subnet $subnet
Get-AzDelegation : Sequence contains no matching element
At line:1 char:1
+ Get-AzDelegation -Name nmeFunction -Subnet $subnet
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzDelegation], InvalidOperationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Network.GetAzureDelegation
```
Would it be better if ```$null``` is returned instead when an object doesn't exist?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Get-AzDelegation command from the issue with a nonexistent delegation and inspect the Az.Network implementation that handles the subnet lookup. Done means the command returns $null when no matching delegation exists instead of raising “Sequence contains no matching element”; add or update coverage for this case if the project’s existing tests expose the command.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.