简体   繁体   English

上载到AzureFile存储不是Blob

[英]Upload to AzureFile Storage Not Blob

Though I'm not a powershell script master I'm having the strugle to upload some ziped files to my Azure File Storage. 尽管我不是Powershell脚本管理员,但我仍在努力将一些压缩文件上传到我的Azure文件存储中。

I've tried the following script which I've scrambled through microsofts guides ( " https://docs.microsoft.com/sv-se/powershell/module/azure.storage/set-azurestoragefilecontent?view=azurermps-1.2.9 ") 我尝试了以下脚本,这些脚本是通过Microsoft指南扰乱的(“ 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'

The problem which I have is i'm getting this error 我遇到的问题是我遇到此错误

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

The share is named archive and inside the archive we have different folders one folder that is named Test. 该共享名为“存档”,在存档中,我们有不同的文件夹,其中一个名为“ Test”。 So I dont get it why it's complaining about the source file missing? 所以我不明白为什么它抱怨源文件丢失了?

First, I don't think you can upload a folder using Set-AzureStorageFileContent . 首先,我认为您无法使用Set-AzureStorageFileContent上载文件夹。 You would need to upload individual files. 您将需要上传单个文件。

Also, there's an issue with the usage of this Cmdlet. 另外,此Cmdlet的用法也存在问题。 Please refer to the documentation here . 请参考here的文档。 Based on the documentation, please try the following: 根据文档,请尝试以下操作:

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

If you wish to upload a folder in Azure File Share , may I suggest you take a look at AzCopy . 如果您希望在Azure File Share上载文件夹,我建议您看一下AzCopy To upload all files from a folder, you would use AzCopy like this: 要上传文件夹中的所有文件,您可以使用AzCopy,如下所示:

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

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

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