Skip to content

Continued NextPageLink when listing key vaults from ARM API #17235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Accounts/Accounts/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-->

## Upcoming Release
* Fixed NextPageLink deserialization issue for ResourceManager
* Fixed the issue that authorization does not work in Dogfood environment
* Enabled Continue Access Evaluation for MSGraph
* Improved error message when login is blocked by AAD
Expand Down
2 changes: 1 addition & 1 deletion src/DnsResolver/Az.DnsResolver.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = './Az.DnsResolver.psm1'

# Version number of this module.
ModuleVersion = '0.1.6'
ModuleVersion = '0.1.0'

# Supported PSEditions
CompatiblePSEditions = 'Core', 'Desktop'
Expand Down
1 change: 1 addition & 0 deletions src/KeyVault/KeyVault/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
* Continued NextPageLink when listing key vaults from ARM API
* `New-AzKeyVaultManagedHsm`: supported specifying how long a deleted managed hsm is retained by `SoftDeleteRetentionInDays` and enabling purge protection by `EnablePurgeProtection`
* `Update-AzKeyVaultManagedHsm`: supported enabling purge protection by `EnablePurgeProtection`
* `Get-AzKeyVaultManagedHsm`: Supported getting or listing deleted managed HSM(s)
Expand Down
12 changes: 10 additions & 2 deletions src/KeyVault/KeyVault/Commands/GetAzureKeyVault.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using Microsoft.Azure.Commands.KeyVault.Helpers;
using Microsoft.Azure.Commands.KeyVault.Models;
Expand Down Expand Up @@ -103,7 +105,13 @@ public override void ExecuteCmdlet()
switch (ParameterSetName)
{
case GetVaultParameterSet:
ResourceGroupName = string.IsNullOrWhiteSpace(ResourceGroupName) ? GetResourceGroupName(VaultName) : ResourceGroupName;
List<PSKeyVaultIdentityItem> vaults = new List<PSKeyVaultIdentityItem>();

if (string.IsNullOrWhiteSpace(ResourceGroupName))
{
vaults.AddRange(ListVaults(ResourceGroupName, Tag));
ResourceGroupName = vaults.FirstOrDefault(r => r.VaultName.Equals(VaultName, StringComparison.OrdinalIgnoreCase))?.ResourceGroupName;
}

if (ShouldGetByName(ResourceGroupName, VaultName))
{
Expand All @@ -115,7 +123,7 @@ public override void ExecuteCmdlet()
}
else
{
WriteObject(TopLevelWildcardFilter(ResourceGroupName, VaultName, ListVaults(ResourceGroupName, Tag)), true);
WriteObject(TopLevelWildcardFilter(ResourceGroupName, VaultName, vaults), true);
}

break;
Expand Down
33 changes: 24 additions & 9 deletions src/KeyVault/KeyVault/Models/KeyVaultManagementCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ protected List<PSKeyVaultIdentityItem> ListVaults(string resourceGroupName, Hash
if (ShouldListByResourceGroup(resourceGroupName, null))
{
listResult = ListByResourceGroup(resourceGroupName,
new Rest.Azure.OData.ODataQuery<GenericResourceFilter>(
r => r.ResourceType == resourceType));
new Rest.Azure.OData.ODataQuery<GenericResourceFilter>(
r => r.ResourceType == resourceType));

}
else
{
Expand All @@ -161,22 +162,36 @@ protected List<PSKeyVaultIdentityItem> ListVaults(string resourceGroupName, Hash
return vaults;
}

public virtual IEnumerable<PSKeyVaultIdentityItem> ListResources(Rest.Azure.OData.ODataQuery<GenericResourceFilter> filter = null, ulong first = ulong.MaxValue, ulong skip = ulong.MinValue)
public virtual IEnumerable<PSKeyVaultIdentityItem> ListResources(Rest.Azure.OData.ODataQuery<GenericResourceFilter> filter = null)
{
IResourceManagementClient armClient = ResourceClient;

return new GenericPageEnumerable<GenericResource>(() => armClient.Resources.List(filter), armClient.Resources.ListNext, first, skip).Select(r => new PSKeyVaultIdentityItem(r));
var response = armClient.Resources.List(filter);
var results = new List<PSKeyVaultIdentityItem>();
results.AddRange(response.Select(r => new PSKeyVaultIdentityItem(r)));
while (!string.IsNullOrEmpty(response.NextPageLink))
{
response = armClient.Resources.ListNext(response.NextPageLink);
results.AddRange(response.Select(r => new PSKeyVaultIdentityItem(r)));
}
return results;
}

private IEnumerable<PSKeyVaultIdentityItem> ListByResourceGroup(
string resourceGroupName,
Rest.Azure.OData.ODataQuery<GenericResourceFilter> filter,
ulong first = ulong.MaxValue,
ulong skip = ulong.MinValue)
Rest.Azure.OData.ODataQuery<GenericResourceFilter> filter)
{
IResourceManagementClient armClient = ResourceClient;

return new GenericPageEnumerable<GenericResource>(() => armClient.ResourceGroups.ListResources(resourceGroupName, filter), armClient.ResourceGroups.ListResourcesNext, first, skip).Select(r => new PSKeyVaultIdentityItem(r));
var response = armClient.ResourceGroups.ListResources(resourceGroupName, filter);
var results = new List<PSKeyVaultIdentityItem>();
results.AddRange(response.Select(r => new PSKeyVaultIdentityItem(r)));

while (!string.IsNullOrEmpty(response.NextPageLink))
{
response = armClient.ResourceGroups.ListResourcesNext(response.NextPageLink);
results.AddRange(response.Select(r => new PSKeyVaultIdentityItem(r)));
}
return results;
}

protected string GetResourceGroupName(string name, bool isHsm = false)
Expand Down
20 changes: 19 additions & 1 deletion tools/Common.Netcore.Dependencies.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
<ItemGroup>
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.23"/>
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.19"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Aks" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.Abstractions" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Authorization" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Common" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Compute" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Graph.Rbac" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.KeyVault" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Monitor" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Network" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.PolicyInsights" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.ResourceManager" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Storage" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Storage.Management" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Strategies" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Websites" Version="1.0.0-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Common.Share" Version="1.0.0-preview"/>
<!--
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Aks" Version="1.3.56-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.Abstractions" Version="1.3.56-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Authorization" Version="1.3.56-preview"/>
Expand All @@ -19,6 +36,7 @@
<PackageReference Include="Microsoft.Azure.PowerShell.Strategies" Version="1.3.56-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Websites" Version="1.3.56-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Common.Share" Version="1.3.56-preview"/>
-->
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.21.0"/>
Expand All @@ -36,7 +54,7 @@
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup>
<StorageToolsPath>$(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.56-preview\tools\</StorageToolsPath>
<StorageToolsPath>$(NugetPackageRoot)\microsoft.azure.powershell.storage\1.0.0-preview\tools\</StorageToolsPath>
</PropertyGroup>
<ItemGroup Condition="'$(OmitJsonPackage)' != 'true'">
<PackageReference Include="Newtonsoft.Json" Version="10.0.3"/>
Expand Down
10 changes: 9 additions & 1 deletion tools/CreateMappings_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@
"group": "Network",
"alias": "Route"
},
{
"group": "DnsResolver",
"alias": "DnsResolver"
},
{
"regex": "Dns",
"group": "Network",
Expand Down Expand Up @@ -671,6 +675,10 @@
"alias": "Private DNS",
"module": "PrivateDns"
},
{
"alias": "Quota",
"module": "Quota"
},
{
"regex": "ContainerInstance",
"alias": "ContainerInstance"
Expand Down Expand Up @@ -715,4 +723,4 @@
"alias": "Lab Services",
"module": "LabServices"
}
]
]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.