你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Get-AzStorageBlobQueryResult
对 Blob 的内容应用简单的结构化查询语言(SQL)语句,并将查询的数据子集仅保存到本地文件。
语法
Get-AzStorageBlobQueryResult
[-Blob] <String>
[-Container] <String>
[-SnapshotTime <DateTimeOffset>]
[-VersionId <String>]
-QueryString <String>
-ResultFile <String>
[-InputTextConfiguration <PSBlobQueryTextConfiguration>]
[-OutputTextConfiguration <PSBlobQueryTextConfiguration>]
[-PassThru]
[-Force]
[-TagCondition <String>]
[-Context <IStorageContext>]
[-ServerTimeoutPerRequest <Int32>]
[-ClientTimeoutPerRequest <Int32>]
[-DefaultProfile <IAzureContextContainer>]
[-ConcurrentTaskCount <Int32>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Get-AzStorageBlobQueryResult
-BlobBaseClient <BlobBaseClient>
-QueryString <String>
-ResultFile <String>
[-InputTextConfiguration <PSBlobQueryTextConfiguration>]
[-OutputTextConfiguration <PSBlobQueryTextConfiguration>]
[-PassThru]
[-Force]
[-TagCondition <String>]
[-Context <IStorageContext>]
[-ServerTimeoutPerRequest <Int32>]
[-ClientTimeoutPerRequest <Int32>]
[-DefaultProfile <IAzureContextContainer>]
[-ConcurrentTaskCount <Int32>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Get-AzStorageBlobQueryResult
-BlobContainerClient <BlobContainerClient>
[-Blob] <String>
[-SnapshotTime <DateTimeOffset>]
[-VersionId <String>]
-QueryString <String>
-ResultFile <String>
[-InputTextConfiguration <PSBlobQueryTextConfiguration>]
[-OutputTextConfiguration <PSBlobQueryTextConfiguration>]
[-PassThru]
[-Force]
[-TagCondition <String>]
[-Context <IStorageContext>]
[-ServerTimeoutPerRequest <Int32>]
[-ClientTimeoutPerRequest <Int32>]
[-DefaultProfile <IAzureContextContainer>]
[-ConcurrentTaskCount <Int32>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
说明
Get-AzStorageBlobQueryResult cmdlet 对 blob 的内容应用简单的结构化查询语言(SQL)语句,并将查询的数据子集保存到本地文件。
示例
示例 1:查询 Blob
$inputconfig = New-AzStorageBlobQueryConfig -AsCsv -HasHeader
$outputconfig = New-AzStorageBlobQueryConfig -AsJson
$queryString = "SELECT * FROM BlobStorage WHERE Name = 'a'"
$result = Get-AzStorageBlobQueryResult -Container $containerName -Blob $blobName -QueryString $queryString -ResultFile "c:\resultfile.json" -InputTextConfiguration $inputconfig -OutputTextConfiguration $outputconfig -Context $ctx
$result
BytesScanned FailureCount BlobQueryError
------------ ------------ --------------
449 0
此命令以 csv 格式查询 blob,并将输出配置为 json,并将输出保存到本地文件“c:\resultfile.json”。
示例 2:查询 Blob 快照
$blob = Get-AzStorageBlob -Container $containerName -Blob $blobName -SnapshotTime "2020-07-29T11:08:21.1097874Z" -Context $ctx
$inputconfig = New-AzStorageBlobQueryConfig -AsCsv -ColumnSeparator "," -QuotationCharacter """" -EscapeCharacter "\" -RecordSeparator "`n" -HasHeader
$outputconfig = New-AzStorageBlobQueryConfig -AsJson -RecordSeparator "`n"
$queryString = "SELECT * FROM BlobStorage WHERE _1 LIKE '1%%'"
$result = $blob | Get-AzStorageBlobQueryResult -QueryString $queryString -ResultFile $localFilePath -InputTextConfiguration $inputconfig -OutputTextConfiguration $outputconfig
$result
BytesScanned FailureCount BlobQueryError
------------ ------------ --------------
187064971 1 {ParseError}
$result.BlobQueryError
Name Description IsFatal Position
---- ----------- ------- --------
ParseError Unexpected token '1' at [byte: 3077737]. Expecting token ','. True 7270632
此命令首先获取 Blob 快照的 Blob 对象,然后查询 Blob 快照并显示结果包括查询错误。
参数
-Blob
Blob 名称
类型: | String |
Position: | 0 |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-BlobBaseClient
BlobBaseClient 对象
类型: | BlobBaseClient |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-BlobContainerClient
BlobContainerClient 对象
类型: | BlobContainerClient |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-ClientTimeoutPerRequest
客户端每个请求的最大执行时间(以秒为单位)。
类型: | Nullable<T>[Int32] |
别名: | ClientTimeoutPerRequestInSeconds |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ConcurrentTaskCount
并发异步任务的总数。 默认值为 10。
类型: | Nullable<T>[Int32] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Confirm
在运行 cmdlet 之前,提示你进行确认。
类型: | SwitchParameter |
别名: | cf |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Container
容器名称
类型: | String |
Position: | 1 |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-Context
Azure 存储上下文对象
类型: | IStorageContext |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-DefaultProfile
用于与 Azure 通信的凭据、帐户、租户和订阅。
类型: | IAzureContextContainer |
别名: | AzureRmContext, AzureCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Force
强制覆盖现有文件。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-InputTextConfiguration
用于处理查询输入文本的配置。 使用 New-AzStorageBlobQueryConfig 创建配置对象。
类型: | PSBlobQueryTextConfiguration |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-OutputTextConfiguration
用于处理查询输出文本的配置。 使用 New-AzStorageBlobQueryConfig 创建配置对象。
类型: | PSBlobQueryTextConfiguration |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-PassThru
返回是否成功查询指定的 Blob。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-QueryString
查询字符串,请参阅:https://learn.microsoft.com/azure/storage/blobs/query-acceleration-sql-reference
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-ResultFile
用于保存查询结果的本地文件路径。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-ServerTimeoutPerRequest
服务器为每个请求超时(以秒为单位)。
类型: | Nullable<T>[Int32] |
别名: | ServerTimeoutPerRequestInSeconds |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-SnapshotTime
Blob SnapshotTime
类型: | Nullable<T>[DateTimeOffset] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-TagCondition
用于检查匹配条件的可选标记表达式语句。 Blob 标记与给定表达式不匹配时,blob 请求将失败。请参阅 https://learn.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations#tags-conditional-operations中的详细信息。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-VersionId
Blob VersionId
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-WhatIf
显示 cmdlet 运行时会发生什么情况。 cmdlet 未运行。
类型: | SwitchParameter |
别名: | wi |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |