简体   繁体   English

需要超时 Get-AzureStorageBlob 函数

[英]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.我尝试添加参数ServerTimeoutPerRequestClientTimeoutPerRequest但它们似乎根本没有帮助,因为命令在 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.

相关问题 Get-AzureStorageBlob捕获异常/错误 - Get-AzureStorageBlob Catch exception / error 没有-blob参数的Get-AzureStorageBlob返回图像两次 - Get-AzureStorageBlob without -blob parameter returns images twice 关于 Powershell 命令 Get-AzureStorageBlob 在 Azure Runbook 中的权限错误 - Error about permission with Powershell command Get-AzureStorageBlob in Azure Runbook Get-AzureStorageBlob throws无法找到您的azure存储凭据 - Get-AzureStorageBlob throws Can not find your azure storage credential Get-AzureStorageBlob:无法获取存储上下文。 请传入存储上下文或设置当前存储上下文 - Get-AzureStorageBlob : Could not get the storage context. Please pass in a storage context or set the current storage context 从AzureStorageBlob下载文件时出现错误 - Getting error while downloading file from AzureStorageBlob Azure Python function 超时 - Azure Python function timeout 找不到 Powershell 错误 Remove-AzureStorageBlob 方法:'无效 - Powershell error Remove-AzureStorageBlob Method not found: 'Void Azure Function App (Python) on App Service Plan Container Timeout with Failed to get HTTP Response After Warmup - Azure Function App (Python) on App Service Plan Container Timeout with Failed to get HTTP Response After Warmup Azure Function GET 发送:您需要启用 JavaScript 才能运行此应用 - Azure Function GET sending: You need to enable JavaScript to run this app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM