寻找帮助 18GB 文件上传并完成到 Azure Blob Storage 的技巧

问题描述 投票:0回答:1

我正在尝试使用 azcopy 将 18GB 的大文件推送到 Azure Blob 存储......我让它适用于较小的文件,但较大的文件似乎被击中或错过。

这是我的脚本,它获取工作站内存,将其压缩并尝试将其上传到 Azure Blob 存储。

$path = "C:\Windows\Temp\"

# Set Azure Blob forensic storage
$AzureURI = "https://something.blob.core.windows.net/storagepath"
# Set Location 
Set-Location -Path C:\Windows\Temp\
$env:AZCOPY_CONCURRENCY_VALUE=4

# Download AzCopy
Invoke-WebRequest -Uri "https://aka.ms/downloadazcopy-v10-windows" -OutFile AzCopy.zip -UseBasicParsing
  
# Expand Archive
Expand-Archive ./AzCopy.zip ./AzCopy -Force

Get-ChildItem ./AzCopy/*/azcopy.exe | Move-Item -Destination "C:\Windows\Temp\azcopy.exe"

# Download Raptor Grab Memory from Azure Blob Storage 
$File = "Raptor_GrabMemory.exe"
$AzureToolURI = "https://something.blob.core.windows.net/forensiccollections/Raptor_GrabMemory.exe?sp=racwl&st=2023-02-27T21:18:50Z&se=2024-02-28T05:1(snip)"
Invoke-WebRequest -Uri $AzureToolURI -OutFile $File

# Grab the memory and zip it
.\Raptor_GrabMemory.exe

# Grab the memory file
$file = Get-Childitem –Path $path -Include CTAM_* -File -Recurse -ErrorAction SilentlyContinue

# use azcopy to push file to blob storage 
.\azcopy.exe cp $file $AzureURI --check-length=false 2>&1

我唯一的成功是将 AZCOPY_CONCURRENCY_VALUE 设置为 4...但即便如此,它仍然是成功或失败的。我不太关心速度,如果这需要 8-10 个小时,只要它完成就没关系。

有人有什么建议吗?

azure azure-blob-storage azure-powershell
1个回答
0
投票

我尝试使用

Azcopy copy
使用以下 PowerShell 将 18 GB 文件上传到 Azure blob,并且上传成功。

$StorageAccountName = "kamalistore"
$ContainerName = "kamali"
$LocalPath = "C:\Windows\storageblob"
$SAS = "SASToken"
$URI = "https://$StorageAccountName.blob.core.windows.net/$ContainerName$SAS"
azcopy copy "$LocalPath" "$URI" --recursive

输出: enter image description here

一旦运行,上述代码文件将成功上传到 Azure blobenter image description here

或者,您可以使用

As-Job
命令将文件复制到 Azure blob。
As-Job
用于检查后端作业状态,同时将大文件上传到 Azure Blob。

$destinationPath = "C:\Windows\storageblob"

$fileName = Split-Path -Path $destinationPath -Leaf
    
$storageAccountConnectionString =
"BlobEndpoint=https://kamalistore.blob.core.windows.net/;QueueEndpoint=https://kamalistore.queue.core.windows.net/;FileEndpoint=https://kamalistore.file.core.windows.net/;TableEndpoint=https://kamalistore.table.core.windows.net/;SASToken"
$containerName = "samplecontainer"
$storageAccountName ="kamalistore"
$resourceGroupName ="Kamali-RG"
$GetStorageAccountContext = Get-AzStorageAccount -Name $storageAccountName -ResourceGroupName $resourceGroupName
$storageContext = $GetStorageAccountContext.Context
Get-ChildItem -File -Recurse | Set-AzStorageBlobContent -Context $storageContext -Container $containerName -AsJob
Get-Job

输出: enter image description here

一旦运行,上述代码文件将成功上传到 Azure blobenter image description here

© www.soinside.com 2019 - 2024. All rights reserved.