question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot call to Local Azurite from within a Docker Container

See original GitHub issue

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

blob

Which version of the Azurite was used?

3.15.0

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

npm

What’s the Node.js version?

12.18.3

What problem was encountered?

Connections to azurite are rejected w/ a 400 “Invalid Storage Account” when the request is made from a docker container using docker.for.mac.host.internal. The same app running locally connects to a local azurite. But running that app in a docker container and I get a 400 from azurite.

Steps to reproduce the issue?

Setup Azurite Local, installed as a local dev dep to the node app Setup a Node App using @azure/storage-blob Connect to Azurite with default Name and Key Run the Node App Locally (Confirm it connects fine with a 200) Put the same Node App in a Docker Container and Run it locally against Azurite, using docker.for.mac.host.internal instead of 127.0.0.1. (Confirm it fails with a 400)

If possible, please provide the debug log using the -d parameter, replacing <pathtodebuglog> with an appropriate path for your OS, or review the instructions for docker containers:

2022-02-25T16:46:28.586Z e500398a-1df6-4a5f-9e74-588247151362 info: BlobStorageContextMiddleware: RequestMethod=GET RequestURL=http://docker.for.mac.host.internal/devstoreaccount1?comp=properties&restype=account RequestHeaders:{"x-ms-version":"2020-10-02","accept":"application/xml","user-agent":"azsdk-js-storageblob/12.8.0 (NODE-VERSION v12.18.3; Linux 5.10.25-linuxkit)","x-ms-client-request-id":"523ba752-4cef-4811-ac30-017faa013b1b","x-ms-date":"Fri, 25 Feb 2022 16:46:28 GMT","authorization":"SharedKey devstoreaccount1:dl7SobnQBLQKAjKC8An60SAmCXm3PJTIZZg0qZUX7Xg=","cookie":"","host":"docker.for.mac.host.internal:10000","connection":"keep-alive"} ClientIP=127.0.0.1 Protocol=http HTTPVersion=1.1
2022-02-25T16:46:28.586Z e500398a-1df6-4a5f-9e74-588247151362 info: BlobStorageContextMiddleware: Account=docker Container=devstoreaccount1 Blob=
2022-02-25T16:46:28.587Z e500398a-1df6-4a5f-9e74-588247151362 verbose: DispatchMiddleware: Dispatching request...
2022-02-25T16:46:28.588Z e500398a-1df6-4a5f-9e74-588247151362 info: DispatchMiddleware: Operation=Container_GetAccountInfo
2022-02-25T16:46:28.588Z e500398a-1df6-4a5f-9e74-588247151362 verbose: AuthenticationMiddlewareFactory:createAuthenticationMiddleware() Validating authentications.
2022-02-25T16:46:28.588Z e500398a-1df6-4a5f-9e74-588247151362 info: PublicAccessAuthenticator:validate() Start validation against public access.
2022-02-25T16:46:28.588Z e500398a-1df6-4a5f-9e74-588247151362 debug: PublicAccessAuthenticator:validate() Getting account properties...
2022-02-25T16:46:28.588Z e500398a-1df6-4a5f-9e74-588247151362 debug: PublicAccessAuthenticator:validate() Retrieved account name from context: docker, container: devstoreaccount1, blob: 
2022-02-25T16:46:28.592Z e500398a-1df6-4a5f-9e74-588247151362 debug: PublicAccessAuthenticator:validate() Skip public access authentication. Cannot get public access type for container devstoreaccount1
2022-02-25T16:46:28.593Z e500398a-1df6-4a5f-9e74-588247151362 info: BlobSharedKeyAuthenticator:validate() Start validation against account shared key authentication.
2022-02-25T16:46:28.593Z e500398a-1df6-4a5f-9e74-588247151362 error: BlobSharedKeyAuthenticator:validate() Invalid storage account docker.
2022-02-25T16:46:28.593Z e500398a-1df6-4a5f-9e74-588247151362 error: ErrorMiddleware: Received a MiddlewareError, fill error information to HTTP response
2022-02-25T16:46:28.594Z e500398a-1df6-4a5f-9e74-588247151362 error: ErrorMiddleware: ErrorName=StorageError ErrorMessage=Invalid storage account.  ErrorHTTPStatusCode=400 ErrorHTTPStatusMessage=Invalid storage account. ErrorHTTPHeaders={"x-ms-error-code":"InvalidOperation","x-ms-request-id":"e500398a-1df6-4a5f-9e74-588247151362"} ErrorHTTPBody="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Error>\n  <Code>InvalidOperation</Code>\n  <Message>Invalid storage account.\nRequestId:e500398a-1df6-4a5f-9e74-588247151362\nTime:2022-02-25T16:46:28.593Z</Message>\n</Error>" ErrorStack="StorageError: Invalid storage account.\n    at Function.getInvalidOperation (/Users/[redacted]/workspace/[redacted]/us4-mig-job/node_modules/azurite/dist/src/blob/errors/StorageErrorFactory.js:58:16)\n    at BlobSharedKeyAuthenticator.validate (/Users/[redacted]/workspace/[redacted]/us4-mig-job/node_modules/azurite/dist/src/blob/authentication/BlobSharedKeyAuthenticator.js:29:49)\n    at AuthenticationMiddlewareFactory.authenticate (/Users/[redacted]/workspace/[redacted]/us4-mig-job/node_modules/azurite/dist/src/blob/middlewares/AuthenticationMiddlewareFactory.js:34:40)\n    at processTicksAndRejections (internal/process/task_queues.js:97:5)"
2022-02-25T16:46:28.594Z e500398a-1df6-4a5f-9e74-588247151362 error: ErrorMiddleware: Set HTTP code: 400
2022-02-25T16:46:28.594Z e500398a-1df6-4a5f-9e74-588247151362 error: ErrorMiddleware: Set HTTP status message: Invalid storage account.
2022-02-25T16:46:28.594Z e500398a-1df6-4a5f-9e74-588247151362 error: ErrorMiddleware: Set HTTP Header: x-ms-error-code=InvalidOperation
2022-02-25T16:46:28.594Z e500398a-1df6-4a5f-9e74-588247151362 error: ErrorMiddleware: Set HTTP Header: x-ms-request-id=e500398a-1df6-4a5f-9e74-588247151362
2022-02-25T16:46:28.594Z e500398a-1df6-4a5f-9e74-588247151362 error: ErrorMiddleware: Set content type: application/xml
2022-02-25T16:46:28.594Z e500398a-1df6-4a5f-9e74-588247151362 error: ErrorMiddleware: Set HTTP body: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Error>\n  <Code>InvalidOperation</Code>\n  <Message>Invalid storage account.\nRequestId:e500398a-1df6-4a5f-9e74-588247151362\nTime:2022-02-25T16:46:28.593Z</Message>\n</Error>"
2022-02-25T16:46:28.595Z e500398a-1df6-4a5f-9e74-588247151362 info: EndMiddleware: End response. TotalTimeInMS=9 StatusCode=400 StatusMessage=Invalid storage account. Headers={"server":"Azurite-Blob/3.15.0","x-ms-error-code":"InvalidOperation","x-ms-request-id":"e500398a-1df6-4a5f-9e74-588247151362","content-type":"application/xml"}

Please be sure to remove any PII or sensitive information before sharing!
The debug log will log raw request headers and bodies, so that we can replay these against Azurite using REST and create tests to validate resolution.

Have you found a mitigation/solution?

No.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
bluewwcommented, Feb 28, 2022

@jlyon87 Have you tried to run Azurite with parameter “–disableProductStyleUrl”?

2reactions
bluewwcommented, Feb 28, 2022

@jlyon87

What’s the command line you use to start Azurite with docker? As you use Uri to connect to Azurite, but account name is not the hostname in the Uri, you need add parameter “–disableProductStyleUrl” when start Azurite.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connect to Azurite from .NET App via Docker - Stack Overflow
I'm passing in the connection string with and env file, but it should work just as well in your local.settings.json file.
Read more >
Use Azurite emulator for local Azure Storage development
The Azurite open-source emulator provides a free local environment for testing your Azure storage applications.
Read more >
Run Azurite in Docker with Rider and keep Azure Storage ...
In this blog post, we'll see how we can use Azurite, an open source Azure Storage API compatible server (emulator), in Docker, and...
Read more >
Local Azure Storage Emulation with Azurite and Azure Functions
If you work with Azure Storage events, you are in the right place. ... ( in older Windows 10 versions Docker support is...
Read more >
Azurite by Microsoft | Docker Hub
Official images for Microsoft Azure Storage Azurite. ... platform experiences for customers wanting to try Azure Storage easily in a local environment.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found