【发布时间】:2019-03-11 07:02:39
【问题描述】:
我正在使用 Azure Functions V2 (.Net core 2.1) This 帖子解释了V2 Azure 函数中的绑定表存储
但我正在寻找的是提供过滤条件以及[Table] 属性。
例如在下面的示例中,我只想获取“PartitionKey”为 {partitionKey} 且 RowKey 为 {rowKey} 的记录,其中 {partitionKey} 和 {rowKey} 属于路由。
[FunctionName("Function2")]
public static async Task<IActionResult> GetPerson(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "api/person/{partitionKey}/{rowKey}")] HttpRequest req
, string partitionKey
, string rowKey
, ILogger log
, [Table("Test", "{partitionKey}",{rowKey} , Connection = "MyConnection")]CloudTable cloudTable
)
{
//I am expecting only records with specified partitionKey and rowKey but its fetching all records like 'select * from Test'
var querySegment = cloudTable.ExecuteQuerySegmentedAsync(new TableQuery<MyEntity>(), null);
foreach (var item in querySegment.Result)
{
log.LogInformation($"{item.PartitionKey} - {item.RowKey} - {item.Name}");
}
预期:
cloudTable 应该只包含具有指定 partitionKey 和 rowKey 的一行
实际
cloudTable 包含所有记录
我正在寻找类似CosmosDb 绑定的东西
[FunctionName("TestFunction")]
public static async Task Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "regos/{queryStringParameter}")]
[CosmosDB(
databaseName: "MyDb",
collectionName: "Table",
CreateIfNotExists = true,
ConnectionStringSetting = "CosmosDBConnectionString",
SqlQuery = "SELECT * FROM Table t where t.Col = {queryStringParameter}")]
IEnumerable<dynamic> list,
以上代码与 Azure Functions V2 完美配合
任何指针?
【问题讨论】:
标签: azure azure-storage azure-functions azure-functions-runtime