使用 AzCopy C# 复制文件
Copying Files Using AzCopy C#
我在使用 AzCopy 将 blob 容器从一个存储帐户复制到另一个存储帐户时遇到问题。
尝试启动进程时出现此错误错误:
知道我为什么会遇到这个问题吗?
unknown command "/Source:https://pslfilestore.blob.core.windows.net/downloads" for "azcopy"
Run 'azcopy --help' for usage.
System.IO.StreamWriterdownloads
unknown command "/Source:https://pslfilestore.blob.core.windows.net/downloads" for "azcopy
"
请看下面的代码
foreach (CloudBlobContainer items in containers)
{
var AzCopyProcess = new Process();
AzCopyProcess.StartInfo.UseShellExecute = false;
AzCopyProcess.StartInfo.RedirectStandardOutput = true;
AzCopyProcess.StartInfo.FileName = strCommand;
//pass storage account name, container and the key
AzCopyProcess.StartInfo.Arguments = $"/Source:https://{storageAccountName}.blob.core.windows.net/{items.Name} /Dest:{dayBlob.Uri}/{storageAccountName}/{items.Name} /SourceKey:{accountKey.ToString()} /DestKey:{pslFileStoreBackUpKey.ToString()} /S";
AzCopyProcess.Start();
StreamWriter stdOut = new StreamWriter(Console.OpenStandardOutput());
stdOut.AutoFlush = true;
Console.Write(stdOut);
var output = AzCopyProcess.StandardOutput.ReadToEnd();
Console.WriteLine($"{items.Name} {output}");
}
根据您的错误报告,您使用的是 AzCopy V10,但您的代码是 V8 格式。我认为这是问题所在。
在 V10 中,复制用法应为:azcopy copy [source] [destination] [flags]
.
复制容器语法应该是:azcopy cp "https://<source-storage-account-name>.blob.core.windows.net/<container-name>" "https://<destination-storage-account-name>.blob.core.windows.net/<container-name>" --recursive
.
有关更多详细信息,您可以参考此文档:Transfer data with AzCopy and Blob storage。或者您可以使用 azure cp --help
来获取详细信息。
我在使用 AzCopy 将 blob 容器从一个存储帐户复制到另一个存储帐户时遇到问题。
尝试启动进程时出现此错误错误:
知道我为什么会遇到这个问题吗?
unknown command "/Source:https://pslfilestore.blob.core.windows.net/downloads" for "azcopy"
Run 'azcopy --help' for usage.
System.IO.StreamWriterdownloads
unknown command "/Source:https://pslfilestore.blob.core.windows.net/downloads" for "azcopy
"
请看下面的代码
foreach (CloudBlobContainer items in containers)
{
var AzCopyProcess = new Process();
AzCopyProcess.StartInfo.UseShellExecute = false;
AzCopyProcess.StartInfo.RedirectStandardOutput = true;
AzCopyProcess.StartInfo.FileName = strCommand;
//pass storage account name, container and the key
AzCopyProcess.StartInfo.Arguments = $"/Source:https://{storageAccountName}.blob.core.windows.net/{items.Name} /Dest:{dayBlob.Uri}/{storageAccountName}/{items.Name} /SourceKey:{accountKey.ToString()} /DestKey:{pslFileStoreBackUpKey.ToString()} /S";
AzCopyProcess.Start();
StreamWriter stdOut = new StreamWriter(Console.OpenStandardOutput());
stdOut.AutoFlush = true;
Console.Write(stdOut);
var output = AzCopyProcess.StandardOutput.ReadToEnd();
Console.WriteLine($"{items.Name} {output}");
}
根据您的错误报告,您使用的是 AzCopy V10,但您的代码是 V8 格式。我认为这是问题所在。
在 V10 中,复制用法应为:azcopy copy [source] [destination] [flags]
.
复制容器语法应该是:azcopy cp "https://<source-storage-account-name>.blob.core.windows.net/<container-name>" "https://<destination-storage-account-name>.blob.core.windows.net/<container-name>" --recursive
.
有关更多详细信息,您可以参考此文档:Transfer data with AzCopy and Blob storage。或者您可以使用 azure cp --help
来获取详细信息。