1
votes

I have an Azure DevOps build pipeline that includes a PowerShell task. That task uploads a file to Azure Storage. At this time, I've created the following script:

PowerShell Script

New-Item -ItemType directory -Path ./test
New-Item -Path ./test -Name "file.txt" -ItemType "file" -Value "hello world"

Compress-Archive -Path ./test/* -DestinationPath ./test.zip

$azureStorageKey = "<MyAccessKey>"
$storage_context = New-AzureStorageContext -StorageAccountName "mystorageaccount" -StorageAccountKey "$azureStorageKey"
Set-AzureStorageBlobContent -Context $storage_context -Container "mycontainer" -File "./test.zip" -Blob "temp/test.zip" -Force

This script successfully runs on my local machine and in Azure DevOps. While I can see the test.zip file in my Azure Storage account, it seems corrupted.

From the Azure Portal, I choose "Download" from the test.zip file blob context menu. The test.zip file gets downloaded to my machine. I then try to unzip the archive file by selecting "Expand All..." from the File Explorer on Windows. When I do that, I receive an error that says:

Windows cannot open the folder.

The Compressed (zipped) Folder 'C:\Users\me\Downloads\test.zip' is invalid.

Why does this archive file seem corrupt? It's fine on my local machine. But, when I download it from the Azure Portal, I can't extract the contents of the archive. What am I missing? Thank you for your help.

1
Have you checked the validness of test.zip before uploading it?Zhaoxing Lu
@ZhaoxingLu-Microsoft - Yes. The test.zip is valid before it's uploaded.Chad Campbell
Any update this issue?Joy Wang-MSFT

1 Answers

1
votes

The issue seems caused by blob storage itself, I can reproduce your issue on my side.

Even if upload and download the compressed file(have test .zipand .rar type) manually in the portal(also test with v1 andv2 tier of storage account), it also gives the error.

You could open a issue in the github, besides, if it is possible, you could use file storage to do that, Managing Azure file shares with Azure PowerShell, it will work fine.

Update:

It may be a bug of azure portal, I download the compressed file in the storage explorer and upzip it, it works fine. So you could try to use storage explorer to do it.