Azurite storage emulator stopping if running multiple projects at once

2.6k Views Asked by At

Good evening, I have been working on the project that has got a web app, api, a few libraries and some Azure functions. When I run only Azure function on its own it works just fine but today I noticed that when I select Multiple startup projects in VS2022 and run all project at once they are all running fine but my azure function is giving me error "No connection could be made because the target machine actively refused it.). In the console output I can see that the emulator starts whenever I start a Visual Studio however after selecting multiple projects I see the message "Stopping Azure Storage Azurite emulator..." I tried to restart Visual Studio but whenever I select it, it stops. Why is it stopping, is there any way how can I prevent stopping it? Thanks enter image description here

2

There are 2 best solutions below

0
On BEST ANSWER

As the default config uses ports of Blob, Queue and Table Services were 127.0.0.1:10000, 10001, 10002.

  • Make Sure no other processes listening on the Azure Storage Emulator Ports.

How to check if any ports are in use:

  • Open the AzureStorageEmulator.exe.config from the path C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator in a text editor.
  • From an administrator command prompt run these commands:
netstat -p tcp -ano | findstr :10000
netstat -p tcp -ano | findstr :10001
netstat -p tcp -ano | findstr :10002

You need to stop if any process is using the above ports or reconfigure the ports in the AzureStorageEmulator.exe.config file in order to be the port not being used by any other application.

  • Again, Run the Command Prompt as Admin > navigate to the above path (Storage Emulator Path) > Run the Command: AzureStorageEmulator.exe init

The storage emulator was successfully initialized and is ready to use - this message you will see if command runs successfully,

If the init command is not successful, check the error details and also the status of Azure Storage Emulator by running this command:

C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator>AzureStorageEmulator.exe status

It should show IsRunning: True

  • If above steps didn't work, then check the Application Event log for any errors by going to the Event Viewer (available on Start button Search).
  • Try to Delete/Reinstall the Azurite or Azure Storage Emulator.

Please check these references for more information:

  1. Run automated tests by using Azurite
  2. Azurite Emulator
  3. Azurite
1
On

If the accepted answer doesn't solve your problem, this worked for me:
Find the Visual Studio option
Projects and Solutions->Service Dependencies->Auto stop local services
and set it to False:

mentioned option in screenshot