Describe the bug
I'm just getting started with the module (so it may be user error) and I have a basic test program trying to list blobs in a container but I get a node.js error when calling listBlobFlatSegment.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A list of blobs in the container. In my case, likely empty because I've never created one.
Screenshots
The error output I get is below.
Exception this._requestPolicyFactories[i].create is not a function
TypeError: this._requestPolicyFactories[i].create is not a function
at StorageClientContext.ServiceClient.sendRequest (/myproject/node_modules/@azure/ms-rest-js/dist/msRest.node.js:4389:64)
at StorageClientContext.ServiceClient.sendOperationRequest (/myproject/node_modules/@azure/ms-rest-js/dist/msRest.node.js:4514:27)
at Container.listBlobFlatSegment (/myproject/node_modules/@azure/storage-blob/dist/index.js:9022:28)
at ContainerURL.
at step (/myproject/node_modules/tslib/tslib.js:136:27)
at Object.next (/myproject/node_modules/tslib/tslib.js:117:57)
at /myproject/node_modules/tslib/tslib.js:110:75
at new Promise (
at Object.__awaiter (/myproject/node_modules/tslib/tslib.js:106:16)
at ContainerURL.listBlobFlatSegment (/myproject/node_modules/@azure/storage-blob/dist/index.js:14802:24)
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage
Pasting the relevant code snippet here.
'use strict';
const Azure = require( '@azure/storage-blob' );
const credentials = {
'sas_token': '...',
'container_name': '...',
'container_uri': '...',
'region': '...',
'account_name': '...'
};
async function go() {
let cred = Azure.TokenCredential( credentials.sas_token );
let pipeline = Azure.StorageURL.newPipeline( cred );
...
TokenCredential takes an OAuth token, not a SAS token. Here's some more information about Azure OAuth2 code flow.
We also realize the gap in our documentation and samples and have been working on improving them in the next preview version of the v12 libraries. See this work item for example.
Please let us know if you have further questions.
So given the credential properties that I have in that object, what Credential object should I be using? I can't use SharedKeyCredential since I don't have a key, and AnonymousCredential gives the same error as TokenCredential.
when you have a uri and a sas token, you would append the sas token to the resource url, then use the anonymous credential type
For example, you can create containerURL without using ServiceURL, something like
const containerUriWithSAS = `${containerUri}?${sasToken}`;
const pipeline = Azure.StorageURL.newPipeline(new Azure.AnonymousCredential());
const containerURL = new Azure.ContainerURL(containerUriWithSAS, pipeline);
Excellent, that is working. Thank you
Thanks for working with Microsoft on GitHub! Tell us how you feel about your experience using the reactions on this comment.