【问题标题】:Transfer multiple files and folder to a Azure storage将多个文件和文件夹传输到 Azure 存储
【发布时间】:2019-07-10 12:39:01
【问题描述】:

我有存放静态网站的地方。我想创建一个任务,将我的构建文件传输到该存储中。

$context = New-AzureStorageContext -StorageAccountName $env:prSourceBranchName -StorageAccountKey "e4Nt0i1pcsYWnzLKw4PRdwu+************/qMj7fXyJK6lS4YTlPCOdbFlEG2LN9g2i5/yQ=="
Get-ChildItem -Path $env:System_DefaultWorkingDirectory/_ClientWeb-Build-CI/ShellArtifact/out/build    
Get-ChildItem -Path $env:System_DefaultWorkingDirectory/_ClientWeb-Build-CI/ShellArtifact/out/build ls -File -Recurse | Set-AzureStorageBlobContent -Container $env:prSourceBranchName -Context $context

当我运行代码时:

我可以看到需要上传的文件,但是当我检查我的 $web blob(由静态网站创建)时,它是空的。

https://docs.microsoft.com/en-us/powershell/module/azure.storage/set-azurestorageblobcontent?view=azurermps-6.13.0查看第二个示例。

谁能解释为什么什么都没发生?

我想这样做 > https://docs.microsoft.com/en-us/cli/azure/storage/blob?view=azure-cli-latest#az-storage-blob-upload-batch 但通过 AzureRM。

【问题讨论】:

  • 嗨彼得,如果下面的答案对你有用,你能帮我把它标记为答案吗?这对其他人会有所帮助。谢谢:)。

标签: azure azure-devops azure-blob-storage


【解决方案1】:

从用于上传到 blob 存储的最后一行代码中删除 ls

变化:

Get-ChildItem -Path $env:System_DefaultWorkingDirectory/_ClientWeb-Build-CI/ShellArtifact/out/build ls -File -Recurse | Set-AzureStorageBlobContent -Container $env:prSourceBranchName -Context $context

收件人:

Get-ChildItem -Path $env:System_DefaultWorkingDirectory/_ClientWeb-Build-CI/ShellArtifact/out/build -File -Recurse | Set-AzureStorageBlobContent -Container $env:prSourceBranchName -Context $context

【讨论】:

  • 我还想分享一下,如果您对 Set-AzureStorageBlobContent 不做任何事情有疑问,您还应该检查您的存储密钥!我的在某些时候是不正确的,并且没有反馈是问题所在。
  • @PeterBoomsma,感谢分享。对于“不正确的存储密钥没有反馈”,如果你能看到输出,你应该看到错误消息说 403 被禁止。
  • 但事实并非如此。当我使用错误的存储密钥时,没有错误消息,根本没有输出。好像函数没有运行。
  • @PeterBoomsma,在 cmdlet Set-AzureStorageBlobContent 的末尾添加 -ErrorAction Stop 怎么样?
猜你喜欢
  • 1970-01-01
  • 2015-05-08
  • 2015-06-10
  • 2011-10-12
  • 2021-04-30
  • 2019-04-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多