Azurite icon indicating copy to clipboard operation
Azurite copied to clipboard

How to create ApplicationTokenCredentials instance for Azure emulator?

Open kannangce opened this issue 4 years ago • 4 comments

Which service(blob, file, queue, table) does this issue concern?

blob

Which version of the Azurite was used?

3.8.0

Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)

DockerHub

What's the Node.js version?

N/A

What problem was encountered?

Need help in creating Authentication file or ApplicationTokenCredentials instance for Azurite.

Steps to reproduce the issue?

N/A

Have you found a mitigation/solution?

N/A

kannangce avatar Aug 19 '20 13:08 kannangce

Hi @kannangce Don't understand your question. What's ApplicationTokenCredentials you are referring to?

XiaoningLiu avatar Aug 21 '20 02:08 XiaoningLiu

@XiaoningLiu My existing code uses authfile based authentication with Azure. For testing , local setup if I have to make a drop-in-replacement of Azurite, I'll be needing one of the below things,

  • An auth file containing the credentials.

  • Java SDK's ApplicationTokenCredentials instance which in turn is created from the auth file, which requires confgurations like ClientId, Client Secret, TenantId and Subsription Id.The mentioned parameters for Azurite is not mentioned in the readme.

If one of the above is possible with Azurite that would be awesome to integrate Azurite in my case.

kannangce avatar Aug 23 '20 00:08 kannangce

Hi @kannangce

It should work. If the token credential works for your production storage account, then it will work for Azurite. Anyway take a try, report any Azurite errors/debug.log here.

XiaoningLiu avatar Aug 27 '20 09:08 XiaoningLiu

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 11:04 stale[bot]

I am also wanting this information. We want to run this in a testing pipeline, however, we will not be injecting production secrets into there for testing purposes....

@XiaoningLiu Specifically:

When using a ClientSecretCredential, which requires a ClientId, TenantId, and a Client Secret, what does this library expect...?

What does azurite expect for the ClientId, TenantId, and Client Secret. Putting fake values in there does not work, and there is no mention in the readme of what is expected here, nor is there a runnable example.

douglasg14b avatar Nov 07 '22 18:11 douglasg14b

@douglasg14b

Guess you are using TokenCredential or similar SDK, which requires you input valid ClientId, TenantId etc. Unluckily the SDK cannot support granting a fake token to Azurite. The SDK will go to AAD asking for a production token.

There are 2 ways you can explorer:

  1. Go to your Azure portal creating an application just for Azurite tests. You can decouple the credentials with your production services. The input ClientId, TenantId using the newly created application credentials.

  2. You can build up code by-yourself to fake tokens to Azurite. Refer to https://github.com/Azure/Azurite/blob/24533376c9bb11ceef005eac5242738032f7196d/tests/blob/oauth.test.ts#L30 and https://github.com/Azure/Azurite/blob/24533376c9bb11ceef005eac5242738032f7196d/tests/testutils.ts#L179

XiaoningLiu avatar Nov 08 '22 05:11 XiaoningLiu