Azure / Azurite

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

A Node.js/JavaScript API #540

Open pellebjerkestrand opened 4 years ago

pellebjerkestrand commented 4 years ago

First: thanks for this project. It works extremely well for all my purposes (except one).

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

All services

Which version of the Azurite was used?

3.8.0

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

npm

What's the Node.js version?

12.18.0

What problem was encountered?

Can not require Azurite in a Node.js context.

Steps to reproduce the issue?

Create a file azurite-require.js with the following content.

require('azurite');

Run the file with node.

node azurite-require

Observe the error message.

Error: Cannot find module 'vscode'

Have you found a mitigation/solution?

Yes, but it's not very ergonomic. This is a stripped down version of what I currently use.

const { spawn } = require('child_process');
const path = require('path');

spawn(
  'azurite',
  ['-s', '-l', './azurite-storage', './azurite-storage/debug.log'],
  {
    cwd: path.resolve(__dirname, '..'),
    shell: true,
    stdio: 'inherit',
  }
);

Wanted behavior

I would like Azurite to be requirable in Node.js so that I can run it as a part of other scripts.

Being "Based on Node.js" and distributed on npm, I expected this to be the case (I'm really not trying to sound entitled here). The current solution doesn't feel very good, and it would be very nice to have an official JavaScript API to more easily be able to run Azurite with other services (I'm currently using Azure Functions Core Tools, Azurite, Browsersync, and Webpack together to develop Azure Functions locally).

blueww commented 4 years ago

@pellebjerkestrand

Thanks for the suggestion! We will evaluate it in our team.