Skip to content

[Identity] Migrated to samples v2#19085

Merged
sadasant merged 11 commits intoAzure:mainfrom
sadasant:identity/samples-v2-fix-14474
Dec 13, 2021
Merged

[Identity] Migrated to samples v2#19085
sadasant merged 11 commits intoAzure:mainfrom
sadasant:identity/samples-v2-fix-14474

Conversation

@sadasant
Copy link
Copy Markdown
Contributor

@sadasant sadasant commented Dec 9, 2021

I’m following the migration guide to move Identity to the samples v2: https://github.com/Azure/azure-sdk-for-js/wiki/Samples-v2-Migration-Guide

Important: Added the dependencyOverrides in order to require @azure/keyvault-keys on the samples, since Identity can’t depend on @azure/keyvault-keys (it would get recursive).

Fixes #14474

@sadasant sadasant self-assigned this Dec 9, 2021
@ghost ghost added the Azure.Identity label Dec 9, 2021
Copy link
Copy Markdown
Member

@witemple-msft witemple-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always only thought of dependencyOverrides as being to override dependency version selectors and not to inject them, but this should totally work and is honestly quite clever.

I have one comment about how the build errors might be fixed, and another about why we need to import from the identity package name and not from ../src.

Comment on lines 8 to 9
import { ClientSecretCredential } from "../src";
import { KeyClient } from "@azure/keyvault-keys";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments here:

  • We need to still be importing from @azure/identity here. Adding it to the paths entry in tsconfig should enable this, so you don't need to import from source for that to resolve (as you can think of paths as adding a manual module resolution entry to the TypeScript compiler).
  • We will also need an entry for @azure/keyvault-keys. I never thought to use dependencyOverrides for this purpose, but it should totally work if we also add a paths entry for it! I think something like "@azure/keyvault-keys": ["../../keyvault/keyvault-keys/src/index"] should work nicely.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I updated the references to @azure/identity on the samples, but "@azure/keyvault-keys": ["../../keyvault/keyvault-keys/src/index"] didn’t work. We talked over teams and we realized that adding keyvault on paths would alter significantly how the dist folder appears (it grabs a large part of the repository structure, to group these two projects under the same root).

@sadasant sadasant marked this pull request as ready for review December 11, 2021 00:05
- [API Reference Documentation](https://docs.microsoft.com/javascript/api/@azure/identity)
- [Product documentation](https://azure.microsoft.com/services/active-directory/)
- [Samples](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples)
- [Samples](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/v2)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think other versions could be added in the future so do we want the customer to pick and choose the right version for them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh interesting! — Though I’d rather not think too much about it at the moment 🙏 I took a peek and it made me question other things. Makes me feel it’s a scope leak and could lead to a rabbit hole.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a peek and it made me question other things.

@sadasant interesting, anything you could share that could help with future migrations?

// Licensed under the MIT license.

/**
* @summary Authenticates with a client and a client's secret.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word client is overloaded in this context and could be confusing. Should we use "application" instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"App Registration"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated! Please let me know how it looks 👍

Copy link
Copy Markdown
Member

@witemple-msft witemple-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice. I have just a couple of comments on the @summary tags.

// Licensed under the MIT license.

/**
* @summary Authenticates with a client and a client's secret.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"App Registration"?

Comment thread sdk/identity/identity/samples-dev/environmentCredential.ts Outdated
Comment thread sdk/identity/identity/samples-dev/defaultAzureCredential.ts Outdated
// Licensed under the MIT license.

/**
* @summary Authenticates with a client and a app registration's secret.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you update this summary as well?

Copy link
Copy Markdown
Contributor Author

@sadasant sadasant Dec 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh now I think I should have said Authenticates with an app registration’s client Id and secret. I’ll update it!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this look? 9f525fc

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@sadasant sadasant enabled auto-merge (squash) December 13, 2021 22:16
@sadasant sadasant merged commit a5289f1 into Azure:main Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[identity] Migrate to Samples Workflow V2

3 participants