Though I'm not a powershell script master I'm having the strugle to upload some ziped files to my Azure File Storage.
I've tried the following script which I've scrambled through microsofts guides ( " https://learn.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. 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
. You would need to upload individual files.
Also, there's an issue with the usage of this Cmdlet. Please refer to the documentation 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
. To upload all files from a folder, you would use AzCopy like this:
AzCopy /Source:C:\myfolder /Dest:https://myaccount.file.core.windows.net/myfileshare/ /DestKey:key /S