gpt4 book ai didi

azure - 使用带有分区键和行键筛选器的 CloudTable 绑定(bind)到 v2 Azure Functions 中的表存储

转载 作者:行者123 更新时间:2023-12-03 00:35:10 25 4
gpt4 key购买 nike

我正在使用 Azure Functions V2 (.Net core 2.1) This帖子解释了V2 Azure Functions 中的绑定(bind)表存储

但我正在寻找的是提供过滤条件以及 [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 绑定(bind)之类的东西

[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 完美配合

有什么指示吗?

最佳答案

尝试 link 中提到的建议

详细了解表存储输入绑定(bind)支持以下 article

[FunctionName("TestFunction")]
public static async Task Run(
[QueueTrigger("test-queue")] string message,
[Table("testTable")] CloudTable testTable)
{
var querySegment = testTable.ExecuteQuerySegmentedAsync(new TableQuery<ResultEntity>(), null);
foreach (ResultEntity item in querySegment.Result)
{
// Access table storage items here
}
}

请告诉我们上述内容是否有帮助或者您在此问题上需要进一步帮助。

关于azure - 使用带有分区键和行键筛选器的 CloudTable 绑定(bind)到 v2 Azure Functions 中的表存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55096680/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com