David Thielen
David Thielen

Reputation: 33006

How can I use Azurite in a command line application?

For my unit tests I want to use Azurite to create & verify BLOBs. The instructions only show how to do this for an ASP.NET app. How can I do it for a command line app?

I tried running Azurite from the command line and got this error:

C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator>azuri
te
Azurite Blob service is starting at http://127.0.0.1:10000
Exit due to unhandled error: Error: EPERM: operation not permitted, open 'C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator\__azurite_db_blob__.json~'

C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator> 

Update: And now I'm getting the following. My Blazor app is not presently running, but was 30 minutes ago.

C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator>azurite
Azurite Blob service is starting at http://127.0.0.1:10000
Exit due to unhandled error: listen EADDRINUSE: address already in use 127.0.0.1:10000

C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator>

And now my unit tests run and can hit Azurite. So it looks like running it from my Blazor app starts it and keeps it running. So that is a solution.

But is there a way to have the command line app start it up if needed?

My configuration is (so shouldn't need any credentials):

 "AzureStorageKey": "UseDevelopmentStorage=true",

  "ConnectionStrings": {
    "AzureStorage": "UseDevelopmentStorage=true"
  },

Note: Azurite is running fine automatically starting when I run my Blazor app from Visual Studio.

Upvotes: 5

Views: 7565

Answers (4)

seekingtheoptimal
seekingtheoptimal

Reputation: 739

It is a tragedy how this tool is unusable with the command line arguments following the official documentation. A simple "solution" is to copy the exe from the default VS folder and put it somewhere convenient. Then it will work as per docs, without having to reference eternally long paths with spaces and .exe etc..

Upvotes: 1

XperiAndri
XperiAndri

Reputation: 1208

In my case, it was an occupied port 10000

I found it with Get-Process -Id (Get-NetTCPConnection -LocalPort 10000).OwningProcess

Thanks to the comment from Christopher Scott https://github.com/Azure/Azurite/issues/803#issuecomment-855932584

Upvotes: 0

BOR15K
BOR15K

Reputation: 468

In addition to your original issue, in my case, when I tried to run azurite.exe from another folder as per various suggestions I found on the Net e.g., from c:\temp, even providing a full valid path like C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator\azurite.exe, I got "access denied" error message enter image description here

In order to fix it, I had to add its location to the PATH like below

enter image description here and it works like a charm now enter image description here

Upvotes: 0

Harshitha
Harshitha

Reputation: 7392

Even I got the same error when I run the azurite from the path which you have mentioned.

enter image description here

Thank you @Gaurav Mantri for the comments.

From this MSDoc, it is clear that no need to go to the Azure Storage Emulator path to run azurite.

Open the CMD, run the command azurite.exe along with the path as shown below.

As I am using the Community edition, I have copied the path of it.

"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator\azurite.exe"

enter image description here

With Professional Edition: enter image description here

I have tried the same by opening the command prompt as an Administrator as well.

I got the same output. enter image description here

As mentioned in the doc, I even tried with the temp path as well.

enter image description here

No need to go to the Azure Storage Emulator path and run azurite.

Instead open the command prompt and run theazurite.exe along with complete path.

In your case, run

"C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator\azurite.exe"
Exit due to unhandled error: >listen EADDRINUSE: address >already in use 127.0.0.1:10000

If one instance is running and you run the same command again in new instance, you will get this error.

I have opened the new cmd prompt and executed the same command again, even I got the same error.

enter image description here

Upvotes: 1

Related Questions