【问题标题】:Upload to AzureFile Storage Not Blob上传到 AzureFile 存储而不是 Blob
【发布时间】:2017-04-05 06:00:56
【问题描述】:

虽然我不是 powershell 脚本大师,但我很难将一些压缩文件上传到我的 Azure 文件存储。

我已经尝试过以下脚本 微软指南(“https://docs.microsoft.com/sv-se/powershell/module/azure.storage/set-azurestoragefilecontent?view=azurermps-1.2.9”)

$StorageAccountName = "MyAccountName"
$StorageAccountKey = "TheKeyThat I have"
$ctx = New-AzureStorageContext -StorageAccountName $StorageAccountName `
         -StorageAccountKey $StorageAccountKey
         Set-AzureStorageFileContent archive archive\Test\ C:\Users\User\Desktop\MoveFrom\*.* -Context $context'

我遇到的问题是这个错误

Set-AzureStorageFileContent : The specified source file 'archive\Test\' was not found.
At line:5 char:10
+          Set-AzureStorageFileContent archive archive\Test\ C:\Users\User\De ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Set-AzureStorageFileContent], FileNotFoundException
    + FullyQualifiedErrorId : FileNotFoundException,Microsoft.WindowsAzure.Commands.Storage.File.Cmdlet.SetAzureStorageFileContent

共享名为存档,在存档中我们有不同的文件夹,其中一个文件夹名为 Test。所以我不明白为什么它抱怨源文件丢失?

【问题讨论】:

    标签: file powershell azure storage powershell-cmdlet


    【解决方案1】:

    首先,我认为您不能使用Set-AzureStorageFileContent 上传文件夹。您需要上传单个文件。

    此外,此 Cmdlet 的使用存在问题。请参阅文档here。根据文档,请尝试以下操作:

    $source = "<path to source file>"
    Set-AzureStorageFileContent -ShareName "archive" -Source $source -Path "Test" -Context $ctx
    

    如果你想上传Azure File Share中的文件夹,我建议你看看AzCopy。要上传文件夹中的所有文件,您可以像这样使用 AzCopy:

    AzCopy /Source:C:\myfolder /Dest:https://myaccount.file.core.windows.net/myfileshare/ /DestKey:key /S
    

    【讨论】:

    • 这没有问题,但我只分配了一个要上传的压缩文件。使用 " $source = "C:\Users\User\Desktop\MoveFrom*.*" " 不行吗?也上传源文件夹中的所有文件?
    • 不,它不会,因为这个 Cmdlet 只会上传一个文件。如果要上传文件夹,可以使用我提到的 AzCopy。
    • 好吧,我尝试了 AzCopy,从链接的页面安装了它。重新启动 POwershell 并具有此命令行(“ AzCopy /C:\Users\User\Desktop\MoveFrom /Dest:StorageName.file.core.windows.net/archive/Test /DestKey:MyKey /S ”)但收到以下错误“术语 'AzCopy' 未被识别为cmdlet 的名称、函数、sc" - 我无法将 Powershell 与 AzCopy 一起使用?
    • 尝试从安装目录运行 AzCopy。您需要打开命令提示符。
    • 设法让它与 azcopy 一起工作。但是有没有办法通过“时间表”来自动化呢?
    猜你喜欢
    • 2014-08-23
    • 2020-05-14
    • 1970-01-01
    • 2017-12-14
    • 2023-03-28
    • 2019-05-26
    • 1970-01-01
    • 1970-01-01
    • 2012-01-08
    相关资源
    最近更新 更多