[英]Need to timeout Get-AzureStorageBlob function
I am using the Get-AzStorageBlob
command to pull out blob files https://learn.microsoft.com/en-us/powershell/module/az.storage/get-azstorageblob?view=azps-9.2.0我正在使用
Get-AzStorageBlob
命令提取 blob 文件https://learn.microsoft.com/en-us/powershell/module/az.storage/get-azstorageblob?view=azps-9.2.0
I want to ignore large-size blobs as they take an eternity to process.我想忽略大型斑点,因为它们需要永恒的时间来处理。 Do we have a way where if this command does not yield output in 10 sec should error out?
如果此命令在 10 秒内未产生输出,我们是否有办法出错?
try{
$blobs = ($container | Get-AzStorageBlob -context $context -ServerTimeoutPerRequest 10 -ClientTimeoutPerRequest 10).LastModified
}
catch {write-output "$($container) timed out"}
I tried adding parameters ServerTimeoutPerRequest
& ClientTimeoutPerRequest
but they seem to not help at all as the command is not erroring out after 10 sec.我尝试添加参数
ServerTimeoutPerRequest
和ClientTimeoutPerRequest
但它们似乎根本没有帮助,因为命令在 10 秒后没有出错。
I tried to reproduce the same in my environment to skip the large files in Blob:我试图在我的环境中重现相同的内容以跳过 Blob 中的大文件:
This is one approach to skip the large files using PowerShell.这是使用 PowerShell 跳过大文件的一种方法。
Based on filesize limit condition, we can fetch the files satisfying the size limit, if any file falls under beyond this size limit will be skipped in fetching.
根据文件大小限制条件,我们可以获取满足大小限制的文件,如果任何文件超出此大小限制将被跳过获取。
I have uploaded 6 Files into my blob.我已将6 个文件上传到我的 blob 中。
Here is the script:这是脚本:
Connect-AzureAD
Install-Module Az.Storage
$MaxReturn = 10000
$ContainerName = "thejademo"
$Token = $Null
$StorageContext = New-AzureStorageContext -StorageAccountName 'venkatsa' -StorageAccountKey 'ky3ewvDbRRMKqVWD75mQXAeojowkYUQFzVSItmgVosrygIG+ITJsrGRgAlVcqo2sY0zlcU2QVNMu+AStJrzWDA=='
$Container = Get-AzureStorageContainer -Name 'thejademo' -Context $StorageContext
$Blobs = Get-AzStorageBlob -Container $ContainerName -MaxCount $MaxReturn -ContinuationToken $Token -Context $StorageContext |where {($_.Length -lt 71458173)}
$Total = $Blobs.count
$Skip= "Skipped Large Blob Files"
Write-Host Total Files $Total in container $ContainerName $skip
Total 6 files in my container but displayed only 4 files (skipped large files).我的容器中共有 6 个文件,但只显示了 4 个文件(跳过了大文件)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.