1

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.

David Thielen
  • 28,723
  • 34
  • 119
  • 193
  • This looks like an issue with permissions. Can you try by running using instructions provided here: https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=visual-studio#workspace-path? Or try to run in elevated command prompt? – Gaurav Mantri Aug 10 '23 at 03:37
  • @GauravMantri Do you have any idea which specifically I should use? I've read that through twice and I'm sure it makes sense to someone familiar with all that. But I'm lost as I've never touched anything having to do with permissions around anything running on my PC. My world of permissions is setting them in Azure or for a database. – David Thielen Aug 10 '23 at 04:35
  • It’s the permission of creating files in the directory where you’re running Azurite. – Gaurav Mantri Aug 10 '23 at 06:04
  • @GauravMantri Ok, that makes sense. But how do I tell it that it can create files? – David Thielen Aug 10 '23 at 13:02
  • You can specify another directory (e.g. `C:\temp`) for these files when starting Azurite (`azurite -l c:\temp`) or open command prompt with elevated permissions (something like `Run as Administrator`). – Gaurav Mantri Aug 10 '23 at 13:31
  • @DavidThielen - Did you get a chance to look into the below solution. – Harshitha Aug 23 '23 at 05:06
  • 1
    @Harshitha What I'm doing is running my Blazor app before running the unit tests. That gets it loaded up. Not a perfect solution, but it works. – David Thielen Aug 23 '23 at 15:47
  • So you are running azurite inside a blazor app. – Harshitha Aug 23 '23 at 16:23
  • I'm doing both. My Blazor app automatically starts it. That's always been fine. My unit tests also try to access it. They do not auto-start it and depend on the Blazor app to have started it. – David Thielen Aug 24 '23 at 00:36

1 Answers1

0

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

Harshitha
  • 3,784
  • 2
  • 4
  • 9