gpt4 book ai didi

Azure 函数 function.json 生成的 scriptFile 路径不正确

转载 作者:行者123 更新时间:2023-12-03 03:02:44 24 4
gpt4 key购买 nike

我终于成功地生成了具有大部分正确属性的 function.json 文件。我仍在努力解决的唯一问题是 scriptFile 路径设置为错误的值。

它生成的值为“bin/MyFunctions.dll”而不是“../bin/MyFunctions.dll”。无论我构建还是发布,都会发生这种情况。

当我尝试运行脚本主机时,出现错误:

The following 1 functions are in error:
Echo: Invalid script file name configuration. The 'scriptFile' property is set to a file that does not exist.

手动将值更改为“../bin/MyFunctions.dll”可以解决该问题。

csproj 文件

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<NoWarn>NU1701</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.0-beta3" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.6" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>

EchoFunction.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs.Host;
using System.Linq;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;

namespace EchoFunctionNameSpace
{
public class EchoFunction
{
[FunctionName("Echo")]
public static IActionResult Run(
[HttpTriggerAttribute(AuthorizationLevel.Anonymous, "get", Route = "name/{name}/sname/{sname}")]
HttpRequest req, TraceWriter log, string name, string sname)
{
log.Info("C# HTTP trigger function processed a request.");

return new OkObjectResult($"Hello {name} {sname}");
}
}
}

主机.json

{}

本地.settings.json

{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"AzureWebJobsDashboard": ""
}
}

这是我仅有的 4 个文件。 dotnet build/publish 生成一个文件 Echo/function.json,如下所示:

{
"generatedBy": "Microsoft.NET.Sdk.Functions.Generator-1.0.6",
"configurationSource": "attributes",
"bindings": [
{
"type": "httpTrigger",
"route": "name/{name}/sname/{sname}",
"methods": [
"get"
],
"authLevel": "anonymous",
"name": "req"
}
],
"disabled": false,
"scriptFile": "bin/AzureFunctions.dll",
"entryPoint": "EchoFunctionNameSpace.EchoFunction.Run"
}

最佳答案

我发现了 SDK 函数生成器代码中的错误。我已在此处提交了拉取请求以尝试解决该问题:

https://github.com/Azure/azure-functions-vs-build-sdk/pull/143

关于Azure 函数 function.json 生成的 scriptFile 路径不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47364144/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com