【问题标题】:Copy From Azure Blob to AWS S3 Bucket从 Azure Blob 复制到 AWS S3 存储桶
【发布时间】:2015-11-08 13:06:38
【问题描述】:

我正在尝试编写一个 PowerShell 脚本,以递归方式从 Azure Blob 复制到 Amazon AWS S3 存储桶,但没有太大成功。

有人可以帮帮我吗?

$container_name = @("<ContainerItemName>")
$connection_string = 'DefaultEndpointsProtocol=https;AccountName=<AccountName>;AccountKey=<AccountKey>'

$storage_account = New-AzureStorageContext -ConnectionString $connection_string

$S3Bucket = "<BucketName>"

foreach ($container_item in $container_name)
{
    $blobs = Get-AzureStorageBlob -Container $container_item -Context $storage_account

    foreach ($blob in $blobs)
    {
        $item = Get-AzureStorageBlobContent -Container $container_item -Blob $blob.Name -Context $storage_account
        Write-S3Object -BucketName $S3Bucket -KeyPrefix $container_item\ -Folder $item -Force
    }
}

【问题讨论】:

    标签: powershell azure amazon-web-services amazon-s3 azure-blob-storage


    【解决方案1】:

    一种选择是使用 Azure 存储数据移动库。您可以在此处下载示例代码:https://github.com/Azure/azure-storage-net-data-movement/tree/master/samples/S3ToAzureSample。以下文章包含有关数据移动库的更多信息:https://azure.microsoft.com/en-us/blog/introducing-azure-storage-data-movement-library-preview-2/

    【讨论】:

      【解决方案2】:

      我没有使用过 AWS PowerShell Cmdlet(所以我可能错了),但快速查看他们的文档 here,我认为您需要先将 blob 保存在本地计算机上,然后指定该路径在您的 Write-S3Object cmdlet -File 参数中。

      将 Azure Blob 下载到目录:

      Get-AzureStorageBlobContent -Container containername -Blob blob -Destination C:\test\
      

      假设 blob 的名称是 blob.png,将其上传到 S3:

      Write-S3Object -BucketName $S3Bucket -KeyPrefix $container_item\ -File "C:\test\blob.png" -Force
      

      【讨论】:

      • 我知道这种方式,但我需要它直接从一个复制到另一个(Blob 到 S3)。
      • 根据我对 S3 的了解,我认为不可能以这种方式创建 S3 对象。您需要将 blob 下载到您的计算机,然后在 S3 中上传该文件。
      猜你喜欢
      • 2019-03-30
      • 2022-10-04
      • 1970-01-01
      • 2021-09-21
      • 1970-01-01
      • 2023-01-17
      • 1970-01-01
      • 2018-07-03
      • 1970-01-01
      相关资源
      最近更新 更多