【问题标题】:Copy directory conents from Az datalakegen2 to different storage account using CLI使用 CLI 将目录内容从 Az 数据湖 gen2 复制到不同的存储帐户
【发布时间】:2023-02-11 21:26:47
【问题描述】:

我正在寻找一种将目录内容复制到不同存储帐户上的目录的方法。这两个存储帐户都是 Azure Data Lake Storage Gen2。我想使用 CLI 来实现这一点。

例如,我在 storageaccount1: datalake/directory/*.parquet 中有文件,我想将它们复制到 storageaccount2: some/path/

我已尝试使用 AzCopy 来完成此操作,但我无法使其正常工作。

AzCopy copy "https://storageaccount1.blob.core.windows.net/raw/2023/02/10/*" "https://storageaccount2.blob.core.windows.net/test"

回应

    INFO: Login succeeded.
PS C:...> 
INFO: Scanning...
INFO: Autologin not specified.
INFO: Authenticating to destination using Azure AD
INFO: Authenticating to source using Azure AD
INFO: Failed to create one or more destination container(s). Your transfers may still succeed if the container already exists.
INFO: Any empty folders will not be processed, because source and/or destination doesn't have full folder support

failed to perform copy command due to error: cannot start job due to error: cannot list files due to reason -> github.com/Azure/azure-storage-blob-go/azblob.newStorageError, /home/vsts/go/pkg/mod/github.com/!azure/azure-storage-blob-go@v0.15.0/azblob/zc_storage_error.go:42
===== RESPONSE ERROR (ServiceCode=InvalidResourceName) =====
Description=The specifed resource name contains invalid characters.
RequestId:xxxxxx
Time:2023-02-10T15:40:31.1266189Z, Details:
   Code: InvalidResourceName
   GET https://x.blob.core.windows.net/xxxxx
   Authorization: REDACTED
   User-Agent: [AzCopy/10.17.0 Azure-Storage/0.15 (go1.19.2; Windows_NT)]
   X-Ms-Client-Request-Id: xxxxx
   X-Ms-Version: [2020-10-02]
   --------------------------------------------------------------------------------
   RESPONSE Status: 400 The specifed resource name contains invalid characters.
   Content-Length: [243]
   Content-Type: [application/xml]
   Date: [Fri, 10 Feb 2023 15:40:30 GMT]
   Server: [Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0]
   X-Ms-Client-Request-Id: [x]
   X-Ms-Error-Code: [InvalidResourceName]
   X-Ms-Request-Id: [x]
   X-Ms-Version: [x]

【问题讨论】:

    标签: azure azure-powershell azure-data-lake-gen2


    【解决方案1】:

    使用以下路径创建了两个 Gen2 存储帐户:

    1. 源存储帐户: harisadlsgen2src (gen2 storage account) >> hari (container name) >> 2023 >> 02 >> 10 (directories)
      • 在源存储帐户层次路径中上传了一些文本文件:
      1. 目标存储帐户: harisadlsgen2dstn (gen2 storage account) >> test (container name)

      笔记:

      1. 容器是在两个存储帐户的容器访问级别上创建的。
      2. 生成SAS 网址具有读取、写入、列表权限,在两个存储帐户容器中创建并根据您的要求修改目录路径。
      3. 使用以下命令打开 Azure CLI 或命令提示符复制工具路径,您必须在所有其他命令 shell 中使用双引号和单引号。
      4. 我用过的命令:
        az login --tenant <your_Azure_Tenant_Id>
        az account set --subscription "<Your_Subscription_Id>"
        azcopy copy "https://harisadlsgen2src.blob.core.windows.net/hari/2023/02/10?sp=<SAS_URL>" "https://harisadlsgen2dstn.blob.core.windows.net/test?sp=<SAS_URL>" --recursive
        

        有关目录内容复制的 Az Copy 命令指南的更多信息,请参阅此 MS Doc

    【讨论】:

      猜你喜欢
      • 2022-07-06
      • 2021-03-26
      • 2022-01-06
      • 1970-01-01
      • 2016-10-23
      • 2021-09-17
      • 2020-11-05
      • 1970-01-01
      • 2018-07-13
      相关资源
      最近更新 更多