-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Storage] Use @azure/core-http in @azure/storage-* libraries to suppo…
…rt @azure/identity (#3853) * Use @azure/core-http in @azure/storage-queue * Use @azure/core-http in @azure/storage-file * Use @azure/core-http in @azure/storage-blob * Rename TokenCredential to RawTokenCredential * Migrate over fixes from @azure/ms-rest-js These changes come from the following two commits: Azure/ms-rest-js@bbeb122 Azure/ms-rest-js@d7ed995 * Add tests and samples for using identity with storage-blob * Add tests and samples for using identity with storage-queue * Make isTokenCredential more resilient * Remove TokenCredential usage from storage-file as it isn't supported yet * Minor tweaks for PR feedback * TokenCredential -> RawTokenCredential in samples * Update BreakingChanges.md for storage-blob and storage-queue * Improve TokenCredential comments in basic samples * Fix type of 'include' field on options types * Move storage-queue TokenCredential tests to node-only
- Loading branch information
Showing
170 changed files
with
3,859 additions
and
4,749 deletions.
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
Oops, something went wrong.