【问题标题】:how do we copy an azure storage account table to another storage account?我们如何将 azure 存储帐户表复制到另一个存储帐户?
【发布时间】:2021-12-23 07:29:21
【问题描述】:

我正在尝试将我的存储表克隆到不同的存储帐户中。使用 powershell 执行此操作的最佳方法是什么?

我尝试了this 解决方案;但是,此时我遇到了这个异常:

Copy-AzureStorageTable : The term 'Copy-AzureStorageTable' is not recognized as the name of a cmdlet, function, script file, or operable program. Check  the spelling  of the 
name, or if a path was included, verify that the path is correct and try again.

我们如何将表复制到另一个存储帐户?

【问题讨论】:

    标签: powershell azure-blob-storage azure-table-storage


    【解决方案1】:

    很遗憾,AzCopy v10 不支持 Azure 表存储。若要从/向 Azure 表存储导出/导入数据,您需要改用 AzCopy v7.3

    注意它不支持直接Table to Table复制,所以需要先将源表导出到本地磁盘或Blob Storage,然后再导入到另一个目标表。 p>

    我们编写了以下 PowerShell 脚本,它将存储帐户下的所有表下载到您的本地,并将上传到运行正常的目标存储帐户。

    这是 PowerShell 脚本:

    Connect-azaccount
    $strgName='<storageAccountName>'
    $stcontext=New-AzStorageContext -StorageAccountName $strgName -StorageAccountKey <StorageAccountKey>
    
    $tablelist=Get-AzStorageTable -Context $stcontext | Select-Object -Property Uri,Name
    
    
    foreach($table in $tablelist){
       
       $Sourceuri=$table.Uri
    
        cd "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy"
    
      .\AzCopy /Source:$Sourceuri /Dest:C:\Users\Downloads\azcopy1 /SourceKey:<StorageAccountKey>
       
    }
    
    $localist=Get-ChildItem -Path C:\users\Downloads\azcopy1\  -Exclude *.json
    foreach( $item in $localist){
    
    $tbname=$item.Name.Replace('<storageaccountName>_','').Replace('.manifest','').Replace('_','').Replace('.','')
    
    $manifest=$item.Name.Replace('C:\users\Downloads\azcopy1\','')
    
     cd "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy" `
    
    .\AzCopy /Source:C:\users\Downloads\azcopy\ /Dest:https://<DestinationStorageAccount>.table.core.windows.net/$tbname/ /DestKey:<DestinationAccountKey> /Manifest:$manifest /EntityOperation:InsertOrReplace
    
    }
    

    这是输出供参考:

    【讨论】:

      猜你喜欢
      • 2015-10-22
      • 2021-08-25
      • 2019-12-30
      • 1970-01-01
      • 2018-02-22
      • 2021-07-27
      • 1970-01-01
      • 2012-01-24
      • 1970-01-01
      相关资源
      最近更新 更多