我正在开发一个应该在 Azure 中运行的 C# 应用程序。我想使用 Azurite emulator 在本地测试它。我想要实现的是:让我的测试检测 Azurite 是否正在运行,如果它没有运行,则通过一条很好的错误消息快速中止。
显然 Azurite 在 Node.js 上运行。
使用旧的 microsoft Azure 存储模拟器,我可以这样检查:
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。
有人知道吗?