azure-blob-storageazure-storageazurite

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.


Solution

  • 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