添加插件后无法在 Rider 中本地运行 Azure Functions 项目

问题描述 投票:0回答:1

我添加了一些插件,以便可以使用 Azure Functions + Azure Service Bus,但此后无法通过 Rider 在本地运行函数。

我尝试过:

  • 删除 bin 和 obj 文件夹
  • 卸载 Azure Toolkit for Rider
  • 删除
    ~\.AzureToolsForIntelliJ
    ~\.azurefunctions
  • 使缓存失效并重新启动 Rider
  • 重新安装 Azure Toolkit for Rider
  • 将所有 Nuget 软件包升级到最新版本

但是这些都不起作用。

按下按钮运行本地Azure功能配置时遇到此错误:

System.Private.CoreLib: Exception has been thrown by the target of an invocation. Microsoft.Azure.WebJobs.Extensions.Storage.Queues: Could not load file or assembly 'System.Memory.Data, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
Value cannot be null. (Parameter 'provider')

当我尝试直接从

func.exe
运行它时遇到此错误:

C:\Users\mail\.AzureToolsForIntelliJ\AzureFunctionsCoreTools\v4\4.104.0\func.exe host start --verbose --pause-on-error --port 7070
MSBuild version 17.8.3+195e7f5a3 for .NET
...
...
...
FUNCTIONS_INPROC_NET8_ENABLED app setting is not enabled in local.settings.json
Selected inproc6 host.
This version of the Azure Functions Core Tools requires your project to reference version 4.5.0 or later of Microsoft.NET.Sdk.Functions. Please update to the latest version. For more information, see: https://aka.ms/functions-core-tools-in-proc-sdk-requirement

这很奇怪,因为它表明我的

Microsoft.NET.Sdk.Functions
已经过时了。然而,看看
.csproj
,却不是:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <AzureFunctionsVersion>v4</AzureFunctionsVersion>
        <RootNamespace />
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)' == 'Release'">
        <RuntimeIdentifier>win-x86</RuntimeIdentifier>
        <PublishReadyToRun>true</PublishReadyToRun>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Azure.Messaging.ServiceBus" Version="7.18.2" />
        <PackageReference Include="Azure.Storage.Queues" Version="12.21.0" />
        <PackageReference Include="Microsoft.Azure.Cosmos" Version="3.46.0-preview.2" />
        <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
        <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.16.4" />
        <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage.Queues" Version="5.3.3" />
        <PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="8.1.0-preview" />
        <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.6.0" />
        <PackageReference Include="PlayFabAllSDK" Version="1.192.241108" />
        <PackageReference Include="Sentry.AspNetCore" Version="4.13.0" />
        <PackageReference Include="Sentry.Extensions.Logging" Version="4.13.0" />
        <PackageReference Include="SharpZipLib" Version="1.4.2" />
        <PackageReference Include="System.Memory" Version="4.6.0" />
    </ItemGroup>
    <ItemGroup>
        <None Update="host.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
        <None Update="local.settings.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
            <CopyToPublishDirectory>Never</CopyToPublishDirectory>
        </None>
    </ItemGroup>
</Project>

这是

func.exe
版本:

C:\Users\mail\.AzureToolsForIntelliJ\AzureFunctionsCoreTools\v4\4.104.0\func.exe --version                              
4.0.6610

任何指点将不胜感激🙏

azure-functions rider
1个回答
0
投票
  • 从 2024 年 11 月 12 日起,对 .NET 6 的支持已停止,因此您需要使用 .NET 8,但我可以在您的 .csproj 文件中看到您仍在使用 .NET 6。

  • 如果您想运行服务总线触发的进程内功能,那么您的 .csproj 文件中应该需要以下包。
  • <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net8.0</TargetFramework> <AzureFunctionsVersion>v4</AzureFunctionsVersion> <RootNamespace>_79189045</RootNamespace> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.16.4" /> <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.6.0" /> </ItemGroup> <ItemGroup> <None Update="host.json"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> <None Update="local.settings.json"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToPublishDirectory>Never</CopyToPublishDirectory> </None> </ItemGroup> </Project>
此外,在本地设置文件中将 

FUNCTIONS_INPROC_NET8_ENABLED

 设置为 1。
{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_INPROC_NET8_ENABLED": "1", "FUNCTIONS_WORKER_RUNTIME": "dotnet", "ServiceBusConnectionString": "Endpoint=sb://afreensb.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=95Gb*****tTJM4=" } }

通过执行给定的更改,您可以在 Rider 中本地运行服务总线触发功能。

Azure Functions Core Tools Core Tools Version: 4.0.6518 Commit hash: N/A +74ed9095fdd6c5326276aae6b8a7d41ccbdeb6aa (64-bit) Function Runtime Version: 4.35.4.23179 [2024-11-15T10:51:45.180Z] Found C:\Users\*****\RiderProjects\79189045\79189045\79189045.csproj. Using for user secrets file configuration. Functions: ServiceBusTriggeredFunction: serviceBusTrigger For detailed output, run func with --verbose flag. [2024-11-15T10:52:58.126Z] Executing 'ServiceBusTriggeredFunction' (Reason='(null)', Id=b4f30256-77aa-4469-be01-72b4e7a12283) [2024-11-15T10:52:58.130Z] Trigger Details: MessageId: 3c75615a8f3c4bc3939c7da0db414d40, SequenceNumber: 1, DeliveryCount: 1, EnqueuedTimeUtc: 2024-11-15T10:52:57.2600000+00:00, LockedUntilUtc: 2024-11-15T10:53:57.2760000+00:00, SessionId: (null) [2024-11-15T10:52:58.147Z] C# ServiceBus queue trigger function processed message: Hi, This is a test message [2024-11-15T10:52:58.173Z] Executed 'ServiceBusTriggeredFunction' (Succeeded, Id=b4f30256-77aa-4469-be01-72b4e7a12283, Duration=100ms)

	
© www.soinside.com 2019 - 2024. All rights reserved.