Azure 函数不在本地启动

Azure function don't start locally

我有 Azure Function 并尝试在本地启动,但启动命令行后不到 1 秒就会显示和隐藏。我试图在屏幕截图中捕捉到它:

似乎没有正确的启动参数。

我的local.settings.json:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
  },
  "ConnectionStrings": {
  }
}

我的 csproj 文件是:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <DebugType>full</DebugType>
    <DebugSymbols>true</DebugSymbols>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SendGrid" Version="3.0.2" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="4.0.4" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
    <PackageReference Include="SendGrid" Version="9.22.0" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\Libraries\Tms.Services\Tms.Services.csproj" />
    <ProjectReference Include="..\..\Libraries\Tms.SlackNotificationCore\Tms.SlackNotificationCore.csproj" />
    <ProjectReference Include="..\..\Libraries\Verizon\VerizonApiImplementation\VerizonApiImplementation.csproj" />
  </ItemGroup>
  <ItemGroup>
    <None Update="Files\EmailTemplate\DailyExtremelyHighUsageNotificationTemplate.html">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="Files\EmailTemplate\DailyExtremelyHighUsageNotificationTemplate.txt">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

此外,我设置了“可执行文件”启动调试 属性 window 和完整路径:

因为没有它 azure 函数根本无法在本地启动并出现错误:

--------------------------- Microsoft Visual Studio --------------------------- The debug executable 'C:\Users\OLEG\AppData\Local\AzureFunctionsTools\Releases.23.5\cli_x64\func.exe' specified in the '...' debug profile does not exist. --------------------------- OK

在哪里可以查看?

这是 Azure function version toolsreferences 可能无法正确下载的原因。

解决此问题的两种方法

删除现有的installation folder(C:\Users\OLEG\AppData\Local\AzureFunctionsTools\Releases.23.5\cli_x64\func。 exe)

并且从visual studio创建一个新的Azure Function应用程序。它将下载新的 azure 函数工具和参考。

您可以重命名您的安装路径….\Releases.23.5\cli_x64\…….\Releases.23.5\cli\...

参考