c# - 在 Azure 存储模拟器中创建表会产生 HTTP 500 错误

标签 c# azure localdb azure-storage-emulator

我一直在尝试通过计算机的 Azure 存储模拟器创建一个表。我可以使用一个仅使用 WindowsAzure.Storage nuget 版本 6.2.0 的非常简单的程序重新创建该问题:

using Microsoft.WindowsAzure.Storage;

namespace StorageEmulatorTest
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var cloudStorageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");
            var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
            cloudTableClient.GetTableReference("JohnnyTest").CreateIfNotExists();
        }
    }
}

25 秒后,这将引发 Microsoft.WindowsAzure.Storage.StorageException 类型的异常,仅显示以下消息:

The remote server returned an error: (500) Internal Server Error.

我尝试过:

  1. 确保我的 WindowsAzure.Storage nuget 包是最新版本 (6.2.0)。
  2. 重新安装 Azure SDK for VS2015 2.8.1(并确保其为最新版本)
  3. 通过 Azure 存储模拟器命令行工具停止、清除、初始化 Azure 存储模拟器(似乎工作正常,没有错误)
  4. 通过异常的“.InnerException.Response.GetResponseStream()”读取网络响应流。此操作失败,并出现异常,指出“流不可读”。
  5. 重新启动我的机器(绝望开始了)

我的技巧包所剩无几了。有人遇到过这个问题吗?

最佳答案

我解决了。我必须完全清除现有的本地存储模拟实例。使用“AzureStorageEmulator.exe clear”或“AzureStorageEmulator.exe init”是不够的。即使卸载 Azure SDK 也不够。

我首先停止存储模拟:

AzureStorageEmulator.exe stop
AzureStorageEmulator.exe clear
AzureStorageEmulator.exe init /forceCreate

最后一个命令出错并表明无法创建数据库。

然后我删除了(实际上,我重命名了它们)这些构成 Azure 存储模拟器背后的数据库的剩余文件:

  • C:\Users\[Me]\AzureStorageEmulatorDb42_log.ldf
  • C:\Users\[Me]\AzureStorageEmulatorDb42_log.mdf

最后,我重新启动了模拟器

AzureStorageEmulator.exe init /forceCreate
AzureStorageEmulator.exe start

成功!

我不确定是什么导致我陷入这种情况,但我最好的猜测是这是由最近的 Azure SDK 升级引起的。

关于c# - 在 Azure 存储模拟器中创建表会产生 HTTP 500 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34662226/

相关文章:

c# - MVC View POST 调用新的构造函数而不是传回模型

c# - 单击 HTML 按钮时的 MVC 5 Razor 变量更改

node.js - 在 Azure Functions 上使用 ImageMagick 或 GraphicsMagick

c# - 使用本地 Db 构建 C# WinForms 应用程序

c# - 有没有用 C# 编写的 ANTLR 的有效替代方案?

c# - 使用小巧玲珑的插入枚举处理

c# - 如何在 Application Insights 中为 Web 作业设置警报并在 Web 作业失败时获取通知

azure - 为什么我在设置 Azure Kubernetes 集群时会在 Terraform 中收到不支持的 block 类型错误?

sql-server - 客户端PC上的LocalDB部署

sql-server - 如何删除系统拥有的localdb实例