[英]Azure Powershell with storage
I want to copy from Azure file share to blob and I am following below refs, and I wanted a incremental copy which is available in azcopy with not in Start-AzureStorageBlobCopy. 我想从Azure文件共享复制到blob,下面是引用,我想要一个增量副本,该副本在azcopy中可用,而在Start-AzureStorageBlobCopy中不可用。 And ofcourse Start-AzureStorageBlobIncrementalCopy wont do copy from file share to blob.
当然,Start-AzureStorageBlobIncrementalCopy也不会从文件共享复制到Blob。
https://docs.microsoft.com/en-us/powershell/module/azure.storage/start-azurestorageblobincrementalcopy?view=azurermps-6.8.1 https://docs.microsoft.com/en-us/powershell/module/azure.storage/start-azurestorageblobincrementalcopy?view=azurermps-6.8.1
https://docs.microsoft.com/en-us/powershell/module/azure.storage/start-azurestorageblobcopy?view=azurermps-6.8.1 https://docs.microsoft.com/en-us/powershell/module/azure.storage/start-azurestorageblobcopy?view=azurermps-6.8.1
I wrote small commands, 我写了一些小命令,
$StorageContext = New-AzureStorageContext -StorageAccountName 'neverdelete' -StorageAccountKey 'XXX'
$Srcsh = Get-AzureStorageFile -ShareName "filetest" -Context $StorageContext
$DestBlob = Get-AzureStorageBlob -Container "client1" -Context $StorageContext
Start-AzureStorageBlobCopy -SrcShare $Srcsh --DestContainer $DestBlob
But this throws an error below: 但这会引发以下错误:
Start-AzureStorageBlobCopy : Cannot convert 'System.Object[]' to the type 'Microsoft.WindowsAzure.Storage.File.CloudFileShare' required by parameter 'SrcShare'. Specified method
is not supported. 不支持。 At line:4 char:38 + Start-AzureStorageBlobCopy -SrcShare $Srcsh --DestContainer $DestBlob + ~~~~~~ + CategoryInfo : InvalidArgument: (:) [Start-AzureStorageBlobCopy], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.StartAzureStorageBlobCopy
在第4行:38个字符:+ Start-AzureStorageBlobCopy -SrcShare $ Srcsh --DestContainer $ DestBlob + ~~~~~~ + CategoryInfo:InvalidArgument:(:) [Start-AzureStorageBlobCopy],ParameterBindingException + FullyQualifiedErrorId:CannotConvertArgument,Microsoft.WindowsAzure .Commands.Storage.Blob.Cmdlet.StartAzureStorageBlobCopy
I dont know what I am doing wrong here and how do I script it so that it could be incremental. 我不知道我在这里做错了什么以及如何编写脚本以使其可以递增。
Thanks, Akshay 谢谢,Akshay
You get the error because the -SrcShare
parameter expects a CloudFileShare
and you pass a list of AzureStorageFile
/ AzureStorageDirectory
. 由于
-SrcShare
参数需要CloudFileShare
并传递了AzureStorageFile
/ AzureStorageDirectory
的列表,因此出现错误。 Also your -DestContainer
has two --
and you are missing the context. 另外,
-DestContainer
有两个--
并且您缺少上下文。
So you could eg iterate over your AzureStorageFiles and invoke the Start-AzureStorabeBlobCopy
cmdlet for each of them: 因此,您可以例如遍历AzureStorageFiles并为每个文件调用
Start-AzureStorabeBlobCopy
cmdlet:
$Srcsh | ForEach-Object {
Start-AzureStorageBlobCopy -SrcShare ($Srcsh[0] | Select-Object -ExpandProperty Share) -SrcFilePath $_.Name -DestContainer "client1" -Context $StorageContext
}
I suppose that you want to copy the files in the storage fileshare to storage container, you could try the command below. 我想您要将存储文件共享中的文件复制到存储容器,可以尝试以下命令。
$StorageContext = New-AzureStorageContext -StorageAccountName 'StorageAccountName' -StorageAccountKey 'xxxxx'
$Srcsh = Get-AzureStorageFile -ShareName "filesharename" -Context $StorageContext | Get-AzureStorageFile
$DestBlob = Get-AzureStorageContainer -Container "containername" -Context $StorageContext
foreach ($item in $Srcsh)
{
Start-AzureStorageBlobCopy -SrcFile $item -DestContainer "DestContainername" -Context $StorageContext
}
My fileshare: 我的文件共享:
Result in the container: 结果在容器中:
For Start-AzureStorageBlobCopy (Start-AzureStorageFileCopy), the cmdlets can only copy single File/Blob, can't copy a share/container, and the copy can't be resume if fail. 对于Start-AzureStorageBlobCopy(Start-AzureStorageFileCopy),这些cmdlet只能复制单个File / Blob,不能复制共享/容器,并且如果失败,则无法继续复制。
The incremental copy ( https://docs.microsoft.com/en-us/rest/api/storageservices/incremental-copy-blob ) can only copy page blob snapshot, and currently File not support it. 增量副本( https://docs.microsoft.com/zh-cn/rest/api/storageservices/incremental-copy-blob )只能复制页面Blob快照,而File目前不支持该快照。 As you say AzCopy support it, what do you means about "incremental copy"?
正如您所说的,AzCopy支持它,“增量复制”是什么意思?
If you want to copy all files in the root directory in a share, you can use following command. 如果要复制共享中根目录中的所有文件,可以使用以下命令。 (Please note, Get-AzureStorageFile will only get the first level file/dir in a share or dir, it won't get the files in subdir.)
(请注意,Get-AzureStorageFile将仅获取共享或目录中的第一级文件/目录,而不会获取子目录中的文件。)
Get-AzureStorageFile -ShareName $shareName -Context $StorageContext
| where {$_.GetType().Name -eq "CloudFile"} |Start-AzureStorageBlobCopy -DestContainer $containerName -DestContext $StorageContext
-context $StorageContext
BTW, for any azure powershell problem, the formal way is to open an issue in https://github.com/Azure/azure-powershell/issues , and the proper team will follow up it. 顺便说一句,对于任何天蓝色的powershell问题,正式的方法是在https://github.com/Azure/azure-powershell/issues中打开一个问题,适当的团队将对其进行跟踪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.