简体   繁体   English

Azure函数,查询存储表

[英]Azure Functions, Query Storage Table

I have the following situation. 我有以下情况。 I am trying to write an Azure function in C#.Net that will read from a Storage Queue (using a trigger), and then look up an entity within an Azure Storage Table. 我正在尝试在C#.Net中编写一个Azure函数,该函数将从存储队列中读取(使用触发器),然后在Azure存储表中查找实体。

To create the function I have used Visual Studio 2017 and have created a functions project. 为了创建函数,我使用了Visual Studio 2017并创建了一个函数项目。 The following reference is in the csproj file. 以下参考文件位于csproj文件中。

<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.2" />

依存关系

Then I follow the instructions on how to read, write and query tables as described here. 然后,按照此处描述的有关如何读取,写入和查询表的说明进行操作。 https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-dotnet https://docs.microsoft.com/zh-cn/azure/cosmos-db/table-storage-how-to-use-dotnet

However, when I add go to install one of the required dependencies such as Install-Package Microsoft.Azure.Storage.Common -Version 9.0.0.1-preview I am unable to as there is a conflict between the version of Newtonsoft.Json I need for the Microsoft.NET.Sdk.Functions dependencies as it can only use 9.0.1. 但是,当我添加安装所需的依赖项之一(例如Install-Package Microsoft.Azure.Storage.Common -Version 9.0.0.1-preview)时,由于我需要的Newtonsoft.Json版本之间存在冲突,我无法进行安装Microsoft.NET.Sdk.Functions依赖项,因为它只能使用9.0.1。

Does anyone know of a solution to resolve this? 有谁知道解决此问题的解决方案?

As you said, the Microsoft.NET.Sdk.Functions is 1.0.2, so one of its dependencies is the Newtonsoft.Json could only use 9.0.1 version. 如您所说,Microsoft.NET.Sdk.Functions为1.0.2,因此其依赖项之一是Newtonsoft.Json只能使用9.0.1版本。

And if you want to install the lastest stable 9.0.0.1 version of Microsoft.Azure.Storage.Common. 如果要安装最新稳定的9.0.0.1版本的Microsoft.Azure.Storage.Common。 It is hard to achieve. 这很难实现。

Because no matter what the version of Microsoft.Azure.Storage.Common is, the Newtonsoft.Json must be >=10.0.2 . 因为无论Microsoft.Azure.Storage.Common的版本是什么, Newtonsoft.Json都必须> = 10.0.2

So, I suggest that you could update the version of Newtonsoft.Json to 10.0.2 and the Microsoft.NET.Sdk.Function will automatically update . 因此,我建议您可以将Newtonsoft.Json的版本更新为10.0.2 ,并且Microsoft.NET.Sdk.Function将自动更新

Then you could install the Microsoft.Azure.Storage.Common. 然后,您可以安装Microsoft.Azure.Storage.Common。

Try using azure timer function and use class library reference. 尝试使用azure计时器函数并使用类库参考。 In class library you can use your latest blob storage version so it will not have dependency on Newtonsoft.Json, and you can write your code in library call it from function. 在类库中,您可以使用最新的Blob存储版本,因此它不会依赖于Newtonsoft.Json,并且可以在库中编写代码,并从函数调用它。 Something like this https://blogs.msdn.microsoft.com/benjaminperkins/2017/04/13/how-to-add-assembly-references-to-an-azure-function-app/ 像这样的东西https://blogs.msdn.microsoft.com/benjaminperkins/2017/04/13/how-to-add-assembly-references-to-an-azure-function-app/

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

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