简体   繁体   English

将Firestore与Azure Functions V2(C#)结合使用

[英]Using Firestore with Azure Functions V2 (C#)

I am trying to use Firestore with Azure Functions, but I'm getting the following error: 我正在尝试将Firestore与Azure Functions结合使用,但是出现以下错误:

System.Private.CoreLib: Exception while executing function: HelloWorld. System.Private.CoreLib:执行函数:HelloWorld时发生异常。 Grpc.Auth: Could not load type 'Grpc.Core.CallCredentials' from assembly 'Grpc.Core.Api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad'. Grpc.Auth:无法从程序集“ Grpc.Core.Api,版本= 1.0.0.0,文化=中性,PublicKeyToken = d754f35622e28bad”中加载类型“ Grpc.Core.CallCredentials”。

I tried to use the steps from this question: 我尝试使用此问题中的步骤:

Grpc.Auth: Could not load type 'Grpc.Core.CallCredentials' from assembly 'Grpc.Core.Api' Grpc.Auth:无法从程序集“ Grpc.Core.Api”加载类型“ Grpc.Core.CallCredentials”

however, it's related to the Language APIs, and the solution doesn't work for Firestore. 但是,它与语言API有关,该解决方案不适用于Firestore。

I tried changing the version of Grpc.Auth to 1.19.0, but this version doesn't appear to be supported by Firestore 1.0.0. 我尝试将Grpc.Auth的版本Grpc.Auth为1.19.0,但是Firestore 1.0.0似乎不支持该版本。

If I remove Firestore from the project and use grps.Auth 1.19.0 to initialize the Credentials object - this works. 如果我从项目中删除Firestore并使用grps.Auth 1.19.0初始化Credentials对象,则可以正常工作。 But the object isn't compatible with Firestore. 但是该对象与Firestore不兼容。

I also tried the PostBuild / PostPublish commands described in that question, but the commands fail to execute. 我还尝试了该问题中描述的PostBuild / PostPublish命令,但是这些命令无法执行。

Before trying to use Firestore with Azure Functions, I successfully managed to use it with a .NET Core Web API project, but I'm struggling with Azure Functions and would appreciate any help. 在尝试将Firestore与Azure Functions结合使用之前,我成功地将其与.NET Core Web API项目结合使用,但是我在Azure Functions方面苦苦挣扎,希望能提供帮助。

It seems that it is a bug in Azure Functions and you could refer to this issue to track it. 看来这是Azure Functions中的错误,您可以参考此问题进行跟踪。

If you update the cli directory to contain the relevant files from Grpc.Core and Grpc.Core.Api , and update func.deps.json accordingly, it all works - including Google.Cloud.Firestore . 如果您更新cli目录以包含Grpc.CoreGrpc.Core.Api的相关文件,并相应地更新func.deps.json ,那么所有这些都将起作用-包括Google.Cloud.Firestore

So basically, this is a problem for any function needing to use a version of Grpc.Core later than the one embedded in the CLI application. 因此,从根本上来说,这对于任何需要使用Grpc.Core版本而不是CLI应用程序中嵌入版本的功能都是一个问题。

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

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