-
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.
- Loading branch information
1 parent
cf7fbad
commit 20ec78a
Showing
2 changed files
with
56 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
Setup: Enter your storage account name and shared key in main() | ||
*/ | ||
|
||
import { BlobServiceClient, newPipeline, SharedKeyCredential } from "../../src"; // Change to "@azure/storage-blob" in your package | ||
|
||
async function main() { | ||
// Enter your storage account name and shared key | ||
const account = ""; | ||
const accountKey = ""; | ||
|
||
// Use SharedKeyCredential with storage account and account key | ||
const sharedKeyCredential = new SharedKeyCredential(account, accountKey); | ||
|
||
// Use sharedKeyCredential, tokenCredential or anonymousCredential to create a pipeline | ||
const pipeline = newPipeline(sharedKeyCredential, { | ||
proxy: { url: "http://localhost:3128" } | ||
}); | ||
|
||
const blobServiceClient = new BlobServiceClient( | ||
// When using AnonymousCredential, following url should include a valid SAS or support public access | ||
`https://${account}.blob.core.windows.net`, | ||
pipeline | ||
); | ||
|
||
// 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