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

问题描述 投票:0回答:1

我正在尝试将一个文件(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 File Service REST API的要求匹配。

预先感谢!

azure powershell azure-storage azure-automation fileshare
1个回答
2
投票

请更改源路径和目标路径。在您的特定情况下,它们应代表相对于共享的路径。

$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指定相对于目标共享的目标文件的路径。

© www.soinside.com 2019 - 2024. All rights reserved.