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

[Identity] Migrated to samples v2 #19085

Merged
merged 11 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
22 changes: 18 additions & 4 deletions sdk/identity/identity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,30 @@
"./dist-esm/src/plugins/consumer.js": "./dist-esm/src/plugins/consumer.browser.js",
"./dist-esm/test/httpRequests.js": "./dist-esm/test/httpRequests.browser.js"
},
"//sampleConfiguration": {
"productName": "Azure Identity",
"productSlugs": [
"azure",
"azure-identity"
],
"dependencyOverrides": {
"@azure/keyvault-keys": "next"
},
"requiredResources": {
"Azure Active Directory App Registration": "https://docs.microsoft.com/azure/active-directory/develop/quickstart-register-app",
"Azure Key Vault": "https://docs.microsoft.com/azure/key-vault/quick-create-portal"
}
},
"scripts": {
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
"build:samples": "echo skipped",
"build:samples": "echo Obsolete.",
"build:test": "tsc -p . && rollup -c 2>&1",
"build": "npm run clean && npm run extract-api && tsc -p . && rollup -c 2>&1",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\" \"samples/**/*.{js,json}\"",
"clean": "rimraf dist dist-* types *.tgz *.log",
"execute:samples": "echo skipped",
"execute:samples": "dev-tool samples run samples-dev",
"extract-api": "tsc -p . && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\" \"samples/**/*.{js,json}\"",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "echo skipped",
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace \"dist-esm/test/public/node/*.spec.js\"",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { ClientSecretCredential } from "@azure/identity";
/**
* @summary Authenticates with a client and a client's secret.
*/

import { ClientSecretCredential } from "../src";
import { KeyClient } from "@azure/keyvault-keys";
Copy link
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
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).


// Load the .env file if it exists
require("dotenv").config();

export async function main(): Promise<void> {
const credential = new ClientSecretCredential(
process.env.AZURE_TENANT_ID!, // The tenant ID in Azure Active Directory
process.env.AZURE_CLIENT_ID!, // The application (client) ID registered in the AAD tenant
process.env.AZURE_TENANT_ID!, // The tenant ID in Azure Active Directory
process.env.AZURE_CLIENT_ID!, // The application (client) ID registered in the AAD tenant
process.env.AZURE_CLIENT_SECRET! // The client secret for the registered application
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { DefaultAzureCredential } from "@azure/identity";
/**
* @summary Tries several authentications. The simplest way to use `@azure/identity`.
sadasant marked this conversation as resolved.
Show resolved Hide resolved
*/

import { DefaultAzureCredential } from "../src";
import { KeyClient } from "@azure/keyvault-keys";

// Load the .env file if it exists
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { EnvironmentCredential } from "@azure/identity";
/**
* @summary Authenticates with a client and a client's secret sent through environment variables.
sadasant marked this conversation as resolved.
Show resolved Hide resolved
*/

import { EnvironmentCredential } from "../src";
import { KeyClient } from "@azure/keyvault-keys";

// Load the .env file if it exists
Expand Down
79 changes: 0 additions & 79 deletions sdk/identity/identity/samples/javascript/README.md

This file was deleted.

35 changes: 0 additions & 35 deletions sdk/identity/identity/samples/javascript/package.json

This file was deleted.

14 changes: 0 additions & 14 deletions sdk/identity/identity/samples/tsconfig.json

This file was deleted.

92 changes: 0 additions & 92 deletions sdk/identity/identity/samples/typescript/README.md

This file was deleted.

43 changes: 0 additions & 43 deletions sdk/identity/identity/samples/typescript/package.json

This file was deleted.

Loading