Azure Table 存储 - 无法建立连接,因为目标机器主动拒绝它 127.0.0.1:10002

Azure Table Storage - No connection could be made because the target machine actively refused it 127.0.0.1:10002

我正在开发一个 ASP.Net MVC 和 WebApi 网站,该网站在 Visual Studio 2015 年 Windows 8 上使用 table 存储。它在开发环境中运行良好(当我在 web.config 中设置 UseDevelopmentStorage=true 时)。我正在尝试点击 "http://localhost:80" 我必须使用它并且不能使用另一个端口,有另一个程序我正在 post 访问我的网站并且它只会 post 到那个位置。

我最近 运行 该站点,当我的代码执行到以下代码行时出现以下错误: CloudTable table = cloudTableClient.GetTableReference(table名称);

错误:

No connection could be made because the target machine actively refused it 127.0.0.1:10002

我试过以下方法:

1) Uninstall-Package WindowsAzure.Storage -Version 6.1.0 并从 NuGet 重新安装它

2) 重新启动 Windows

3) 在这里浏览 C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.7\binran cspack.ext(我看不到任何其他似乎与存储相关的内容)

还没运行宁。 关于我可以尝试什么的任何想法?

更新:

出现上述错误后,我打开了 Cloud Explorer window,可以看到我在 dev 中使用我的代码在本地创建的 tables(假设这意味着我的本地存储模拟器是运行ning) 但我仍然遇到错误。然后我关闭 window 并再次打开它。它在扩展 "Storage Accounts (Classic)" 时旋转了一点,但最终显示了我创建的 tables。

奇怪的是 "Cloud Explorer" window 中唯一的节点是 "Storage Accounts (Classic)",我敢肯定之前有其他节点的列表(即 WebApps 等)。如果有人可以帮助解决这个问题,请 post 逐步说明如何操作(而不是 "the emulator is not running" 之类的)。对此很陌生,所以正在寻找我奶奶会理解的简单说明。

非常感谢。

您必须启动存储模拟器。它位于 %programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe.

作为奖励,这里有一个用于清理和启动模拟器的批处理脚本。

SET emu="%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe"
%emu% stop
%emu% clear all
%emu% start

更新

可以找到经典和 "new" 存储帐户之间的区别

Classic storage accounts are created using existing Service Management API's (the REST API stack that's been available for the past several years). The newer storage accounts are created with the new Azure Resource Manager (ARM) API's (which are also wrapped in PowerShell and CLI now). Ultimately they provide the same resources to your apps, but they're created/managed differently, and there are a few nuanced differences (such as the ability to tag resources that are created via ARM scripts).

You can't convert a classic storage account (or any classic resource) to a newer type. You don't really need to anyway, unless you're trying to mix resources from classic and new, such as adding ARM-based virtual machines to a classic-based virtual network, or spin up an ARM-based VM from a vhd image sitting in a classic storage account (and for that example, you could always just copy the vhd to a new storage account). Note that, for general storage usage (blobs/tables/queues), you just need the URI and the primary (or secondary) key. With those, you can access your storage resources from anywhere, from any VM/website/etc, regardless if you're accessing storage from classic or new virtual machines, for example.

TL;DR:不同之处在于 API 用于管理存储帐户。现有 API 和用于 downloading/uploading 数据到容器的 SDK 两者都适用。

我在调试 Durable 函数时 运行 遇到了这个确切的错误。接受的答案帮助了我。只是想指出我无法通过单击文件来启动模拟器。相反,我是通过(从上面的 link 发布的另一个用户)

开始的
  • Select 开始按钮或按 Windows 键。
  • 开始输入 Azure 存储模拟器。
  • Select 显示的应用程序列表中的模拟器。

模拟器启动后,错误消失,我能够启动我的持久函数。

我认为这里最简单的解决方案是为 VS/VSCode 安装官方 Azurite 扩展。然后,您可以使用 Azurite: Start Table Service (VSCode) 或 Windows shell (VS) 中的相关命令 运行 存储模拟器。有关详细信息,请参阅 here