<PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.0.1" />
Microsoft.NET.Sdk.Functions
用于VS开发。再次导入它可能会导致生成错误,如您所见。
既然你看不见
function.json
内建资产,恐怕出了问题
在您这边,它无法在.cs文件中构建触发器属性
. 我的建议是
-
删除函数SDK
%userprofile%\.nuget\packages\microsoft.net.sdk.functions
.
-
用VS删除函数CLI
%localappdata%\AzureFunctionsTools
-
删除VS使用的模板引擎
%userprofile%\.templateengine
.
-
重新启动VS并创建一个新的函数项目,在creation/template对话框的底部,请参见
Making sure all templates are up to date
Updates are ready
.
-
点击
Refresh
.
为了防止您需要检查,我在VS中使用了服务总线队列触发器模板。代码如下,.csproj与所讨论的相同,没有
Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator
.
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace FunctionApp1
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([ServiceBusTrigger("myqueue", Connection = "MyConnection")]string myQueueItem, ILogger log)
{
log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}
}
}
以及中的文件夹结构
[Functionproject]\bin\Debug\netstandard2.0
.