2017-04-05 86 views
0

儘管我不是PowerShell腳本高手,但我正在使用strugle將一些ziped文件上傳到我的Azure文件存儲。上傳到AzureFile存儲不是Blob

我已經試過我已經通過微軟 導遊(「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的文件夾。所以我不明白爲什麼它抱怨源文件丟失?

回答

0

首先,我不認爲您可以使用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 
+0

這可以毫無問題地工作,但我只分配了一個需要上載的ziped文件。不會使用「$ source =」C:\ Users \ User \ Desktop \ MoveFrom \ *。*「」?是否也上傳了源文件夾中的所有文件? – Wookoai

+0

不會,因爲此Cmdlet只會上傳單個文件。如上所述,您可以使用AzCopy來上傳文件夾。 –

+0

嗯,我試過AzCopy,從鏈接的頁面安裝它。重新啓動POwershell並且有這個命令行(「AzCopy/C:\ Users \ User \ Desktop \ MoveFrom /Dest:https://StorageName.file.core.windows.net/archive/Test/DestKey:MyKey/S」),但得到以下錯誤「術語'AzCopy'不被識別爲cmdlet的名稱,函數,sc」 - 我無法在AzCopy中使用Powershell? – Wookoai

相關問題