-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Storage] Use @azure/core-http in @azure/storage-* libraries to support @azure/identity #3853
Merged
daviwil
merged 15 commits into
Azure:feature/storage
from
daviwil:storage-use-core-http
Jun 24, 2019
+3,859
−4,749
Merged
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a2da333
Use @azure/core-http in @azure/storage-queue
daviwil 2bf85f0
Use @azure/core-http in @azure/storage-file
daviwil defe175
Use @azure/core-http in @azure/storage-blob
daviwil 5de642a
Rename TokenCredential to RawTokenCredential
daviwil 5bf9601
Migrate over fixes from @azure/ms-rest-js
daviwil 997c3fc
Add tests and samples for using identity with storage-blob
daviwil dd3a731
Add tests and samples for using identity with storage-queue
daviwil 570d93c
Make isTokenCredential more resilient
daviwil 36cd16f
Remove TokenCredential usage from storage-file as it isn't supported yet
daviwil a024718
Minor tweaks for PR feedback
daviwil dfce54a
TokenCredential -> RawTokenCredential in samples
daviwil 134e793
Update BreakingChanges.md for storage-blob and storage-queue
daviwil 6088a8b
Improve TokenCredential comments in basic samples
daviwil aa06008
Fix type of 'include' field on options types
daviwil 0cf4ae6
Move storage-queue TokenCredential tests to node-only
daviwil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
sdk/storage/storage-blob/samples/javascript/azureAdAuth.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Setup: Enter your Azure Active Directory credentials as described in main() | ||
*/ | ||
|
||
const { BlobServiceClient } = require("../.."); // Change to "@azure/storage-blob" in your package | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
|
||
async function main() { | ||
// Enter your storage account name | ||
const account = ""; | ||
|
||
// DefaultAzureCredential will first look for Azure Active Directory (AAD) | ||
// client secret credentials in the following environment variables: | ||
// | ||
// - AZURE_TENANT_ID: The ID of your AAD tenant | ||
// - AZURE_CLIENT_ID: The ID of your AAD app registration (client) | ||
// - AZURE_CLIENT_SECRET: The client secret for your AAD app registration | ||
// | ||
// If those environment variables aren't found and your application is deployed | ||
// to an Azure VM or App Service instance, the managed service identity endpoint | ||
// will be used as a fallback authentication source. | ||
const defaultAzureCredential = new DefaultAzureCredential(); | ||
|
||
const blobServiceClient = new BlobServiceClient( | ||
`https://${account}.blob.core.windows.net`, | ||
defaultAzureCredential, | ||
); | ||
|
||
// Create a container | ||
const containerName = `newcontainer${new Date().getTime()}`; | ||
const createContainerResponse = await blobServiceClient | ||
.createContainerClient(containerName) | ||
.create(); | ||
console.log(`Created container ${containerName} successfully`, createContainerResponse.requestId); | ||
} | ||
|
||
// An async method returns a Promise object, which is compatible with then().catch() coding style. | ||
main() | ||
.then(() => { | ||
console.log("Successfully executed the sample."); | ||
}) | ||
.catch((err) => { | ||
console.log(err.message); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
sdk/storage/storage-blob/samples/typescript/azureAdAuth.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Setup: Enter your Azure Active Directory credentials as described in main() | ||
*/ | ||
|
||
import { BlobServiceClient, SharedKeyCredential } from "../../src"; // Change to "@azure/storage-blob" in your package | ||
import { DefaultAzureCredential } from "@azure/identity"; | ||
|
||
async function main() { | ||
// Enter your storage account name | ||
const account = ""; | ||
|
||
// DefaultAzureCredential will first look for Azure Active Directory (AAD) | ||
// client secret credentials in the following environment variables: | ||
// | ||
// - AZURE_TENANT_ID: The ID of your AAD tenant | ||
// - AZURE_CLIENT_ID: The ID of your AAD app registration (client) | ||
// - AZURE_CLIENT_SECRET: The client secret for your AAD app registration | ||
// | ||
// If those environment variables aren't found and your application is deployed | ||
// to an Azure VM or App Service instance, the managed service identity endpoint | ||
// will be used as a fallback authentication source. | ||
const defaultAzureCredential = new DefaultAzureCredential(); | ||
|
||
const blobServiceClient = new BlobServiceClient( | ||
`https://${account}.blob.core.windows.net`, | ||
defaultAzureCredential, | ||
); | ||
|
||
// Create a container | ||
const containerName = `newcontainer${new Date().getTime()}`; | ||
const createContainerResponse = await blobServiceClient | ||
.createContainerClient(containerName) | ||
.create(); | ||
console.log(`Created container ${containerName} successfully`, createContainerResponse.requestId); | ||
} | ||
|
||
// An async method returns a Promise object, which is compatible with then().catch() coding style. | ||
main() | ||
.then(() => { | ||
console.log("Successfully executed the sample."); | ||
}) | ||
.catch((err) => { | ||
console.log(err.message); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "Ad" or "Aad"? is this file name
azureAdAuth.ts
correct?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I called it "azureAd" to refer to "Azure Active Directory", though I can see how having "aad" explicitly could make things clearer. I'll ask someone about this and will rename these files after the PR gets merged if necessary.