c# - 来自 Visual Studio 2017 的 Azure 函数调试连接出现 'N/A' 监听器连接错误

标签 c# visual-studio azure visual-studio-2017 azure-functions

我在 Visual Studio 2017(包含最新更新)中启动一个新项目并创建一个 Azure Function。我将存储帐户添加到 local.settings.json 中,并将存储帐户的连接字符串粘贴到 AzureWebJobsStorage 中。

[FunctionName("Function1")]
    public static void Run([EventHubTrigger("wms-events", Connection = "ConnectionStringTest1")]string myEventHubMessage, TraceWriter log)
    {
        log.Info($"C# Event Hub trigger function processed a message: {myEventHubMessage}");
    }

The listener for function 'Function1' was unable to start. Microsoft.ServiceBuss: An error occurred during communication with 'N/A'. Check the connection information, then retry. System: An existing connection was forcibly closed by the remote host.

为什么是“不适用”?我会假设这是 WebStorage 连接,并且我知道这是一个合法的连接字符串。

enter image description here

连接字符串示例(已混淆)

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=stuff;AccountKey=UCIdr7FscQQIJhRkJ4rsstuffstuffstuffzKwRZ1QG4EC9bIhJx+x11CVg9dd1AElMBUkw==;EndpointSuffix=core.windows.net",
    "AzureWebJobsDashboard": "DefaultEndpointsProtocol=https;AccountName=stuffstuffstuff;AccountKey=UCIdr7FscQQIJhRkstuffstuffstuff3/zZ5FyGJ3MdzKwRZ1QG4EC9bIhJx+x11CVg9dd1AElMBUkw==;EndpointSuffix=core.windows.net",
    "ConnectionStringTest1": "Endpoint=sb://stuffstuffstuff.servicebus.windows.net/;SharedAccessKeyName=AzureFunction;SharedAccessKey=SVfahzJQE5ustuffstuffstuff1zrgAOUPI+yfp63pRA=;EntityPath=stuffstuffstuff"
  }
}

最佳答案

你是如何获得ConnectionStringTest1的?它应该是 eventhub 连接字符串(不是服务总线)。您可以使用门户上的共享访问策略获取 Evenhub 命名空间或 eventhub 级别的连接字符串:

https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-create

关于c# - 来自 Visual Studio 2017 的 Azure 函数调试连接出现 'N/A' 监听器连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46810348/

相关文章:

c# - 打印缩放我的 WPF-GroupBox

windows - 视觉小尺寸语言

c# - 在 Visual Studio 中使用自定义方法时在 View 名称上显示红色下划线

Azure ARM模板依赖于复制循环中的资源

c# - 从 Windows 8 商店应用程序获取当前登录的用户

c# - 在没有管理员权限的情况下运行 taskmgr.exe?

c++ - CPU 密集型 OpenGL 函数

azure - 为什么我无权访问 Azure 门户中的 AAD 应用程序注册,但可以使用 Azure CLI 查看它?

azure - Web API 身份验证最佳实践

c# - 检查应用程序的先前版本