Bri*_*ing 25 azure azure-storage azure-table-storage azure-sql-database
我正在使用Azure存储资源管理器查询Azure表存储.我想找到包含给定文本的所有消息,如T-SQL中的这样:
message like '%SysFn%'
Run Code Online (Sandbox Code Playgroud)
执行T-SQL会出现"处理此请求时出错"
Azure中此查询的等效内容是什么?
虽然高级通配符搜索在 Azure 表存储中严格来说是不可能的,但您可以使用“ge”和“lt”运算符的组合来实现“前缀”搜索。Scott Helme在此处的博客文章中解释了此过程。
本质上,此方法使用 ASCII 递增来查询 Azure 表存储,以查找属性以特定文本字符串开头的任何行。我编写了一个小型 Powershell 函数,用于生成执行前缀搜索所需的自定义过滤器。
Function Get-AzTableWildcardFilter {
param (
[Parameter(Mandatory=$true)]
[string]$FilterProperty,
[Parameter(Mandatory=$true)]
[string]$FilterText
)
Begin {}
Process {
$SearchArray = ([char[]]$FilterText)
$SearchArray[-1] = [char](([int]$SearchArray[-1]) + 1)
$SearchString = ($SearchArray -join '')
}
End {
Write-Output "($($FilterProperty) ge '$($FilterText)') and ($($FilterProperty) lt '$($SearchString)')"
}
}
Run Code Online (Sandbox Code Playgroud)
然后,您可以像这样使用此函数Get-AzTableRow(其中 $CloudTable 是您的Microsoft.Azure.Cosmos.Table.CloudTable对象):
Get-AzTableRow -Table $CloudTable -CustomFilter (Get-AzTableWildcardFilter -FilterProperty 'RowKey' -FilterText 'foo')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15171 次 |
| 最近记录: |