简体   繁体   English

Azure功能无法正常运行VS2017

[英]Azure Functions Not Working VS2017

I've downloaded VS2017 Community Edition to try out Azure functions and I can't get it to work. 我已经下载了VS2017社区版以试用Azure功能,但无法正常使用。 I've searched many post on Stackoverflow and Azure functions Github pages but nowhere there seems to be a complete documentation about anything. 我在Stackoverflow和Azure函数Github页面上搜索了很多帖子,但是似乎没有关于任何内容的完整文档。

Here's what I have: 这是我所拥有的:

Azure function: Azure功能:

namespace FunctionApp1
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([ServiceBusTrigger("ngctestqueue", AccessRights.Manage, Connection = "Endpoint=sb://ngcservicebus.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SERVICE_BUS_KEY")]string myQueueItem, TraceWriter log)
        {
            log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
        }
    }
}

host.json host.json

{
  "disabled": false,
  "bindings": [
    {
      "name": "myQueueItem",
      "type": "serviceBusTrigger",
      "direction": "in",
      "queueName": "ngctestqueue",
      "connection": "connection",
      "accessRights": "manage"
    }
  ]
}

local.settings.json local.settings.json

{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=ngctest2;AccountKey=STORAGE_ACCOUNT_KEY;EndpointSuffix=core.windows.net",
    "AzureWebJobsDashboard": "DefaultEndpointsProtocol=https;AccountName=ngctest2;AccountKey=STORAGE_ACCOUNT_KEY;EndpointSuffix=core.windows.net",
    "AzureWebJobsServiceBus": "Endpoint=sb://ngcservicebus.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SERVICE_BUS_KEY",
    "connection": "Endpoint=sb://ngcservicebus.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SERVICE_BUS_KEY"
  }
}

When I run the function via F5 locally, I get the following error: 当我通过F5在本地运行该函数时,出现以下错误:

Microsoft.Azure.WebJobs.Host: Error indexing method 'Func
tion1.Run'. Microsoft.Azure.WebJobs.ServiceBus: Microsoft Azure WebJobs SDK Serv
iceBus connection string 'AzureWebJobsEndpoint=sb://ngcservicebus.servicebus.win
dows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SERVICE_BUS_KEY' is missing or empty.

My dev environment is as follows: 我的开发环境如下:

1) Windows 8.1 Pro 1)Windows 8.1专业版

2) VS2017 Community 15.3.5 2)VS2017社区15.3.5

3) Azure Functions CLI 1.0.4 3)Azure Functions CLI 1.0.4

Any help would really be appreciated. 任何帮助将不胜感激。

Thank you. 谢谢。

Connection property should be set to connection string name, not the value itself. Connection属性应设置为连接字符串名称,而不是值本身。 The value will then be read from the config. 然后将从配置中读取该值。

[ServiceBusTrigger("ngctestqueue", AccessRights.Manage, Connection = "AzureWebJobsServiceBus")]

You don't need to create host.json in local environment (it will be auto-generated by SDK). 您无需在本地环境中创建host.json (它将由SDK自动生成)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM