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

upload entire folder to a specific folder on Azure blob

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

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

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

谢谢

你可以试试命令行工具AzCopy or its core library Azure Storage Data Movement Library,它支持文件夹快速传输,可以暂停和恢复。

要在容器中创建文件夹,我们只需要使用路径和文件名的组合作为 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 }

这是我实验室的截图:

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

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