Azure存储-使用PowerShell上传.zip文件

时间:2018-09-17 19:48:27

标签: azure powershell azure-storage azure-storage-blobs

我有一个包含PowerShell任务的Azure DevOps构建管道。该任务将文件上传到Azure存储。目前,我创建了以下脚本:

PowerShell脚本

sp.plot(eqn, (x, -2*sp.pi, 2*sp.pi), ylim=(-1, 1))

此脚本在我的本地计算机和Azure DevOps中成功运行。虽然我可以在我的Azure存储帐户中看到 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 文件,但该文件似乎已损坏。

我从Azure门户的test.zip文件blob上下文菜单中选择“下载”。 test.zip文件已下载到我的机器上。然后,我尝试通过在Windows的文件资源管理器中选择“全部扩展...”来解压缩存档文件。当我这样做时,我收到一条错误消息:

test.zip

为什么此存档文件似乎已损坏?在我的本地机器上也可以。但是,当我从Azure门户下载它时,无法提取存档的内容。我想念什么?谢谢您的帮助。

1 个答案:

答案 0 :(得分:1)

该问题似乎是由Blob存储本身引起的,我可以在您这边重现您的问题。

即使在门户中手动上传和下载压缩文件(已测试.zip.rar类型)(也使用存储帐户的v1v2层进行测试) ),它也会给出错误信息。

您可以在github中打开一个问题,此外,如果可能的话,您可以使用file storage进行操作,Managing Azure file shares with Azure PowerShell,它将正常工作。

更新

这可能是azure门户网站的错误,我将压缩文件下载到了存储资源管理器中并对其进行了上压缩,效果很好。因此,您可以尝试使用storage explorer来做到这一点。