Azure / Azurite

A lightweight server clone of Azure Storage that simulates most of the commands supported by it with minimal dependencies
MIT License
1.86k stars 327 forks source link

[FeatureRequest] VsCode Command for checking if azurite blob service is running or start service only if service is not running #2395

Open YunchuWang opened 7 months ago

YunchuWang commented 7 months ago

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

blob

Which version of the Azurite was used?

Azurite.azurite v3.30.0

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

Visual Studio Code Extension

What's the Node.js version?

v20.12.2

What problem was encountered?

I am from azure function team, we are building an vscode.dev extension which needs to start azurite blob service as part of our extension startup experience for customer every time reloading extension. we dont want to start blob service if it is already running nor see the error vscode window. right now dont see thats possible in vscode azurite commands.

Steps to reproduce the issue?

  1. build an extension which installs and invoke vscode.commands.executeCommand('azurite.start_blob'); to be called every time page refresh once.
  2. refresh the page you will see the error message image

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:

-d "<pathtodebuglog>"

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. We would need help if azurite vscode extension can :

  1. add a new command to check if azurite service is already running
  2. change existing start commands to allow an option to start if only if not running
  3. a way to suppress the popup window for detecting address already in use.
  4. suggest any workaround.
blueww commented 6 months ago

@YunchuWang

Thanks for the suggestion! However this might not be so appliable to Azurite.

  1. We can start several Azurite instance on same host machine, with different (customized) ports. So we should not block start Azurite instances when Azurite already started.
  2. Azurite has several distribution package currently, like npm, docker, VScode extension. Even we add detection for Azurite started in VS code, VS code might don't have permission to detect if Azurite started with docker of npm and will still see this error.
  3. The reason why this Azurite can't be start is caused by the port is occupied (it can be occupied by other process, not only existing Azurite instance). Azurite might don't have permission to detect if the port is occupied by another Azurite or other process. So we just report the real reason for the error.
  4. We need to show the error when Azurite not start successfully, or other customer might be confused as Azurite not started and no error is reported.

One workaround might be: detect if the Azurite port (by default: 10000,10001,100002) is occupied, if so, don't start Azurite. With this way, you need to make sure only Azurite can occupied the related ports on your client machine.