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.