Skip to content

Commit

Permalink
Fixed null subscriptions exception, added change log
Browse files Browse the repository at this point in the history
  • Loading branch information
makharch committed Jun 9, 2021
1 parent 914fa40 commit cc484e5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/ResourceGraph/ResourceGraph/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Fixed the output print issue for `Search-AzGraph`. Fixed the issue when Search-AzGraph fails when no subscriptions are stored in the context.

## Version 0.10.0
* Changed output of `Search-AzGraph` to PSResourceGraphResponse which wrapped previous output under Data property.
Expand Down
4 changes: 2 additions & 2 deletions src/ResourceGraph/ResourceGraph/Cmdlets/SearchAzureRmGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public override void ExecuteCmdlet()
IList<string> subscriptions = null;
if (managementGroups == null)
{
subscriptions = this.GetSubscriptions().ToList();
subscriptions = this.GetSubscriptions()?.ToList();
if (subscriptions != null && subscriptions.Count > SubscriptionLimit)
{
subscriptions = subscriptions.Take(SubscriptionLimit).ToList();
Expand Down Expand Up @@ -262,7 +262,7 @@ private IEnumerable<string> GetSubscriptions()
}

var accountSubscriptions = this.DefaultContext.Account.GetSubscriptions();
if (accountSubscriptions.Length > 0)
if (accountSubscriptions?.Length > 0)
{
return accountSubscriptions;
}
Expand Down
5 changes: 3 additions & 2 deletions src/ResourceGraph/ResourceGraph/help/Search-AzGraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ A complex query on resources featuring field selection, filtering and summarizin

### Example 3
```powershell
PS C:\> Search-AzGraph -Query 'project id, name' -SkipToken 'skiptokenvaluefromthepreviousquery=='
PS C:\> $response = (Search-AzGraph -Query 'project id, name' -First 1000)
PS C:\> Search-AzGraph -Query 'project id, name' -SkipToken $response.SkipToken
id : /subscriptions/1ef51df4-f8a9-4b69-9919-1ef51df4eff6/resourceGroups/Service-INT-b/providers/Microsoft.Compute/virtualMachineScaleSets/nt2
Expand All @@ -74,7 +75,7 @@ id : /subscriptions/1ef51df4-f8a9-4b69-9919-1ef51df4eff6/resourceGroups/
name : egtopic-2
```

A query with the skip token passed from the previous query results
A query with the skip token passed from the previous query results. Please note that keeping id in the results is mandatory to get back a skip token.

### Example 4
```powershell
Expand Down

0 comments on commit cc484e5

Please sign in to comment.