Skip to content
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

[KeyVault] Update @azure/ms-rest-azure-js to 2.0.0 in @azure/keyvault #4530

Closed
2 of 6 tasks
kepikoi opened this issue Jul 30, 2019 · 8 comments
Closed
2 of 6 tasks

[KeyVault] Update @azure/ms-rest-azure-js to 2.0.0 in @azure/keyvault #4530

kepikoi opened this issue Jul 30, 2019 · 8 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. KeyVault

Comments

@kepikoi
Copy link

kepikoi commented Jul 30, 2019

  • Package Name: @azure/keyvault
  • Package Version: 0.1.0
  • Operating system:
  • nodejs
    • version: 10.15.3
  • browser
    • name/version:
  • typescript
    • version: 3.5.3
  • Is the bug related to documentation in

Describe the bug
@azure/keyvault throws a known serialization bug from #911 due to an outdated version of @azure/ms-rest-js when calling:

import {KeyVaultClient} from "@azure/keyvault";
 private async authClient(): Promise<KeyVaultClient> {
        let authRe: msRestNodeAuth.AuthResponse;

        authRe = await msRestNodeAuth.loginWithServicePrincipalSecretWithAuthResponse(this.clientId, this.clientSecret, this.azureTenantId, {
                tokenAudience: "https://vault.azure.net",
        });

        return new KeyVaultClient(authRe.credentials);
    }

 public async getAllKeys(): Promise<IKeyListResponse> {
        const
            client = await this.authClient()
        ;
        let keys: KeyListResult;
        keys = await client.getKeys(this.vaultUrl); // fixme: throws!

To Reproduce

  1. Create a new KeyVault
  2. Call await client.getKeys(this.vaultUrl); on the empty vault (no Keys)
  3. Error is thrown
TypeError: (_response.parsedBody || []).slice is not a function
    at flattenResponse (D:\proj\node_modules\@azure\ms-rest-js\lib\serviceClient.ts:554:60)
    at D:\proj\node_modules\@azure\ms-rest-js\lib\serviceClient.ts:324:22
    at process._tickCallback (internal/process/next_tick.js:68:7)
[ 'TypeError: (_response.parsedBody || []).slice is not a function' ]```

**Expected behavior**
Error is not thrown and and concise result is returned for the request

**Screenshots**

**Additional context**
@maggiepint maggiepint added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. KeyVault and removed triage labels Jul 30, 2019
@maggiepint
Copy link
Contributor

@schaabs - can you take a look here?

@ramya-rao-a
Copy link
Contributor

I believe all we need to do here is to re-generate the library using version 4.2.0 of the generator.
@daviwil should be able to kick this off if @schaabs has no concerns

@daviwil
Copy link
Contributor

daviwil commented Nov 13, 2019

Hi @kepikoi, I tried to reproduce this issue with @azure/keyvault 0.1.0 (@azure/ms-rest-js 1.8.13 and @azure/ms-rest-nodeauth 1.1.1) and did not encounter the same error. If you're still using @azure/keyvault could you try again and let us know if the issue still persists for you?

Also, we've deprecated this library in favor of the @azure/keyvault-keys and @azure/keyvault-secrets libraries which have had many improvements since @azure/keyvault has been released, so you should also give those a try!

@kepikoi
Copy link
Author

kepikoi commented Nov 14, 2019

Hi @daviwil strange, I cannot reproduce it anymore... I will close the issue then.

I'm also looking into @azure/keyvault-keys but as far as I can see there seems no way to get the continuation token or URL from the listPropertiesOfKeys().byPage() iterable. @azure/keyvault's getKeys() does return nextLink as part of the server response though.
Oddly enough listPropertiesOfKeys().byPage() does allow a continuationToken option. What am I missing?

@kepikoi kepikoi closed this as completed Nov 14, 2019
@ghost
Copy link

ghost commented Nov 14, 2019

Thanks for working with Microsoft on GitHub! Tell us how you feel about your experience using the reactions on this comment.

@daviwil
Copy link
Contributor

daviwil commented Nov 14, 2019

Could you tell me a little more about what you're trying to accomplish by using the nextLink or continuationToken directly? It does look like we don't expose that directly anymore so it'd be helpful to understand whether there's another use case we could account for.

@sophiajt
Copy link
Contributor

@kepikoi - you can get access to the continuationToken via the page settings object.

Something like:

  let pageSettings: PageSettings = {continuationToken: undefined, maxPageSize: 2};

  const page = client.listPropertiesOfSecrets().byPage(pageSettings);

  const secretProperties = (await page.next()).value;
  for (const secretProperty of secretProperties) {
    const secret = await client.getSecret(secretProperty.name);
    console.log("secret: ", secret);  
  }

  console.log("continuation: ", pageSettings.continuationToken);

@kepikoi
Copy link
Author

kepikoi commented Nov 15, 2019

@daviwil I employ a lots of keys per Key Vault and need to return key properties to my client's management frontend swiftly. Iterating over almost 2000 keys takes right now ~2 minutes that is why I pass the continuationToken to the frontend allowing to fetch results incrementally.

@jonathandturner works for me! thank you very much

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. KeyVault
Projects
None yet
Development

No branches or pull requests

6 participants