Azure-sdk-for-js: SharedKeyCredential is not exported in azure-storage.blob.js

Created on 13 May 2019  Â·  13Comments  Â·  Source: Azure/azure-sdk-for-js

  • Package Name:
    azure-storage.blob.js
  • Package Version:
    10.3
  • Is the bug related to documentation in

Describe the bug
The documentation says
const sharedKeyCredential = new SharedKeyCredential(accountName, accessKey);
but SharedKeyCredential is not exported by azblob global (I use UMD in browser).
Therefore I get TypeError: SharedKeyCredential is not a constructor when I run the aforementioned code.

Expected behavior
Either fix the readme or fix the lib :)

Client Storage customer-reported enhancement question

Most helpful comment

this caught me up too and wasted a bit of time. Javascript V2 libs, Javascript V10 libs.... i think the microsoft docs should add something that clearly describes proper storage account setup and usage in React apps

All 13 comments

Ah, I've just read here https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/storage/storage-blob that SharedKeyCredential is only available in node environment.
Anyway, I think you should clearly mention it in https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/storage

@XiaoningLiu - Can you make sure that docs reflect the above information correctly?

It's already mentioned in readme.md and JSDocs.

https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/storage
image

I would mark it here, in code comments; specifically for those who skip introductions (too much text) and go straight for the API :)
image

@avalanche1 Yeah, we can do that. We always like coding directly and don't like too much documents : )

I'm trying to do this from a local react app, but I'm still getting this error.
I thought react was a node.js app. Am I missing something?

@sposaro What does the "local react app" do? If the uploading happens in browser, then it's a browser usage scenario.

@xiaoningliu Yes. By “local react app” I was referring to browser. Thanks for clearing that up for me. You also mentioned that I can use v10 and install via npm and use SAS key. That would explain why I wasn’t able to gain access to this function.

this caught me up too and wasted a bit of time. Javascript V2 libs, Javascript V10 libs.... i think the microsoft docs should add something that clearly describes proper storage account setup and usage in React apps

One thing that really helped me get back on track was actually creating the
new templated project in Visual Studio. I created a .net core backend
serving up a React App. From there I was able to create the SAS with C# and
simply pass it to React.

In my particular case, I was starting with blank React App and this got
confused about how to connect to the entire backend. After I saw this
template and how .net serves the React JS things made much more sense.

On Tue, Jun 18, 2019 at 5:48 PM SogoGolf notifications@github.com wrote:

this caught me up too and wasted a bit of time. Javascript V2 libs,
Javascript V10 libs.... i think the microsoft docs should add something
that clearly describes proper storage account setup and usage in React apps

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Azure/azure-sdk-for-js/issues/2862?email_source=notifications&email_token=AABLDD6FIREU6R5D7FEH7ILP3F66FA5CNFSM4HMS3EGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYALNOQ#issuecomment-503363258,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABLDD2FK3M2GUBYR33ROV3P3F66FANCNFSM4HMS3EGA
.

>

Frank Sposaro
-Microsoft Engineer-

thanks @sposaro . still having trouble getting this working in our React app. would you mind sharing a snippet of how you're connecting to storage (obviously hide the SAS token), then (say) uploading or downloading a blob ?

fyi our setup is simply a React app, that accesses CosmosDB via Azure Functions. (ie. we're not running a VM on server side)

SharedKeyCredential is not something we support in the browser. Since this issue has evolved from it's original question (which I believe was answered), I'm closing the issue.

@SogoGolf, @sposaro, @avalanche1 Thanks for reaching out and commenting. If you have any other questions or bugs that you find in our preview libraries, don't hesitate in opening a new issue to get help!

Thanks for working with Microsoft on GitHub! Tell us how you feel about your experience using the reactions on this comment.

Was this page helpful?
0 / 5 - 0 ratings