繁体   English   中英

使用 Azure 自动化帐户,跨存储将文件从一个文件共享复制到另一个文件共享

[英]Using Azure Automation Account, Copy files from one Fileshare to another Fileshare across Storage

我正在尝试将一个文件 (x) 从存储 (z) 的文件共享 (y) 复制到存储 (b) 的文件共享 (a)。

$StorageAccountName = "z"
$StorageAccessKey = 
"md226fZvTKPKaCd9TxDGPn4mitCPfvBvgzElwoqIgpbf2Pe09GKKfNJlMcK2EXXqRLqOrhBslybaE1Cpz2BcPg=="
$context1=New-AzureStorageContext $StorageAccountName $StorageAccessKey

$DestStorageAccountName = "b"
$DestStorageAccessKey = "xZjU0r5g5fU+/ieAbwc22OmVtFY5BJdQuF8OZsFd7hGHYLzQFGg9ZCpsVnQi5u6Wi/nigb8jdupUGo0YaXBphg=="
$destcontext1=New-AzureStorageContext $DestStorageAccountName $DestStorageAccessKey
$SrcPath = "https://z.file.core.windows.net/y/x"
$SrcShare = "y"
$DestPath = "https://b.file.core.windows.net/a"
$DestShare = "a"
Start-AzureStorageFileCopy -SrcFilePath $SrcPath -SrcShareName $SrcShare -DestShareName $DestShare - 
DestFilePath $DestPath -Context $context1 -DestContext $destcontext1 -Force

它给了我如下错误:

Start-AzStorageFileCopy:给定的路径/前缀“https:”不是文件或目录的有效名称,或者不符合 Microsoft Azure 文件服务 REST ZDB974238714CA8DE634A7ACED1 的要求

提前致谢!

请更改源路径和目标路径。 在您的特定场景中,它们应该代表相对于共享的路径。

$StorageAccountName = "z"
$StorageAccessKey = 
"md226fZvTKPKaCd9TxDGPn4mitCPfvBvgzElwoqIgpbf2Pe09GKKfNJlMcK2EXXqRLqOrhBslybaE1Cpz2BcPg=="
$context1=New-AzureStorageContext $StorageAccountName $StorageAccessKey

$DestStorageAccountName = "b"
$DestStorageAccessKey = "xZjU0r5g5fU+/ieAbwc22OmVtFY5BJdQuF8OZsFd7hGHYLzQFGg9ZCpsVnQi5u6Wi/nigb8jdupUGo0YaXBphg=="
$destcontext1=New-AzureStorageContext $DestStorageAccountName $DestStorageAccessKey
$SrcPath = "test.txt" #assuming the name of the source file is "test.txt"
$SrcShare = "y"
$DestPath = "test.txt" #assuming you want to copy the file and keep the same name
$DestShare = "a"
Start-AzureStorageFileCopy -SrcFilePath $SrcPath -SrcShareName $SrcShare -DestShareName $DestShare - 
DestFilePath $DestPath -Context $context1 -DestContext $destcontext1 -Force

从文档link

-SrcFilePath指定源文件相对于源目录或源共享的路径。

-DestFilePath指定目标文件相对于目标共享的路径。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM