我正在开发一个应该在 Azure 中运行的 C# 应用程序。我想使用Azurite 模拟器在本地进行测试。我想要实现的是:让我的测试检测 Azurite 是否正在运行,如果它没有运行,则快速中止并显示一个很好的错误消息。
显然 Azurite 在 Node.js 上运行。
使用旧的 Microsoft Azure Storage Emulator,我可以像这样检查它:
public static class AzureStorageEmulatorDetector
{
public static bool IsRunning()
{
const string exePath = @"C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe";
if (!File.Exists(exePath))
return false;
var processStartInfo = new ProcessStartInfo {FileName = exePath, Arguments = "status", RedirectStandardOutput = true};
var process = new Process {StartInfo = processStartInfo};
process.Start();
process.WaitForExit();
var processOutput = process.StandardOutput.ReadToEnd();
return processOutput.Contains("IsRunning: True");
}
}
我想用 Azurite 完成类似的事情。
我已经像这样安装了 Azurite:
npm install -g azurite
我这样运行它:
azurite --silent --location C:\temp\Azurite --debug c:\temp\Azurite\debug.log
我注意到 Azurite 命令行应用程序没有告诉我它是否已经在运行的参数。当我从控制台启动 Azurite 时,我在任务资源管理器中看不到任何名为“azurite”的进程或服务。所以我不知道我应该检查什么过程。
编辑:显然 Azurite 在 Node.js 上运行。确实有一个过程叫做node.exe
运行,但这不是充分条件。我可以查询我正在运行的 Node.js 实例并让它告诉我它在做什么吗?
我在 Windows 上。
有人知道吗?