2017-03-13 4 views
2

Azure 함수에서 테이블 저장소의 데이터를 읽는 중입니다. 테이블 스토리지 바인딩에서 HttpTrigger 함수를 만들었습니다. 프로젝트 저장 패키지를 사용하고 있습니다 :Azure 함수 테이블 바인딩의 저장소가 매개 변수 'TElement'형식의 제약 조건을 위반합니다.

"WindowsAzure.Storage": "8.0.0" 

및 바인딩 :

{ 
    "bindings": [ 
    { 
     "authLevel": "anonymous", 
     "name": "req", 
     "type": "httpTrigger", 
     "direction": "in" 
    }, 
    { 
     "name": "$return", 
     "type": "http", 
     "direction": "out" 
    }, 
    { 
     "name": "metadataTable", 
     "type": "table", 
     "direction": "in", 
     "tableName": "metadata", 
     "connection": "StorageConnectionString", 
     "partitionkey": "some_partition_key" 
    } 
    ], 
    "disabled": false 
} 

내가 매개 변수에 새로 추가 한 템플릿에 의해 생성 된 코드를 가졌 : 나는 무엇입니까 저장하고 실행 과정에서

#r "Microsoft.WindowsAzure.Storage" 

using System; 
using System.Net; 
using Microsoft.WindowsAzure.Storage.Table; 
using Microsoft.WindowsAzure.Storage; 

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, 
        IQueryable<MetadataTable> metadataTable, TraceWriter log) 
{ 
..... 
} 
public class MetadataTable: TableEntity 
{ 
    public MetadataTable():base() { } 

    public MetadataTable(string partitionkey, string rowkey):base(partitionkey,rowkey) {} 

    public string Data { get; set; } 
} 

컴파일 오류 :

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.HttpTriggerCSharp1'. Microsoft.Azure.WebJobs.Host: GenericArguments[0], 'Submission#0+MetadataTable', on 'Microsoft.Azure.WebJobs.Host.Tables.TableAttributeBindingProvider+TableToIQueryableConverter 1[TElement]' violates the constraint of type 'TElement'. mscorlib: GenericArguments[0], 'Submission#0+MetadataTable', on 'Microsoft.Azure.WebJobs.Host.Tables.TableAttributeBindingProvider+TableToIQueryableConverter 1[TElement]' violates the constraint of type parameter 'TElement'.

누구든지이 문제를 해결하거나 동일한 오류를 만날 수 있습니까?

답변

4

오류 메시지가 약간 이상하게 보입니다. 그러나 project.json 파일에서 WindowsAzure.Storage 참조를 제거하십시오. 이 패키지는 런타임에 의해 자동으로 참조되며 명시 적으로 포함하면 버전 불일치로 인해 모든 종류의 오류가 발생합니다.

패키지 참조없이 코드에서 깨끗한 Azure 함수를 만들었으므로 제대로 컴파일되고 작동했습니다. 같은 것을 시도하십시오.

+0

Mikhail에게 감사드립니다. Azure 함수 호스팅 환경 (Newtonsoft.Json, Microsoft.WindowsAzure.Storage 등)에 의해 자동으로 추가되는 어셈블리에 대한 특정 버전을 어떻게 설정할 수 있습니까? – Leszek

+0

아니요, 그러한 가능성을 알지 못합니다. – Mikhail

+1

Visual Studio 2017에서 만든 function app에 project.json 또는 WindowsAzure.Storage에 대한 참조가있는 것과 동일한 문제가 있습니다. [31/08/2017 12:49:20] 실행 : Microsoft.Azure.WebJobs.Host : 인덱싱 방법 'SearchTrucks.Run'오류가 발생했습니다. Microsoft.Azure.WebJobs.Host : 'Microsoft.Azure.WebJobs.Host.Tables.TableExtension + TableToIQueryableConverter'1 [TElement]의 GenericArguments [0],'NNN.NNN.NNN '이'TElement '유형의 제약 조건을 위반합니다. . mscorlib : –