将整个文件夹上载到Azure blob上的特定文件夹

时间:2016-08-29 18:29:52

标签: azure-storage-blobs azure-powershell

我知道如何将整个文件夹上传到Azure blob上的包含,它是这样的:

Get-ChildItem -File -Recurse | Set-AzureStorageBlobContent -Container $ContainerName -Context $ctx

我的问题是,如果我的容器下有一个文件夹,说它是" test"。如何将本地文件夹的所有文件/子载体上传到Azuure blob mycontainer / test /。

由于

3 个答案:

答案 0 :(得分:5)

要在容器中创建文件夹,我们只需要使用路径和文件名的组合作为blob名称。

Get-ChildItem返回的对象有一个名为FullName的属性。然后我们可以使用substring方法删除磁盘字母。

Get-ChildItem -File -Recurse C:\Test\ | ForEach-Object { Set-AzureStorageBlobContent -File $_.FullName -Blob $_.FullName.Substring(3) -Container uploaded -Context $ctx }

以下是我实验室的截图:

Lab

答案 1 :(得分:1)

您可以尝试命令行工具AzCopy或其核心库Azure Storage Data Movement Library,它支持文件夹的快速传输,并且可以暂停&恢复。

答案 2 :(得分:1)

现在可以将文件添加到blob存储到文件夹中。您只需下载Microsoft Azure Storage Explorer即可。然后,您可以使用它来编辑blob存储中的文件和文件夹:

enter image description here

或直接从Azure打开应用程序:

enter image description here