I created an Azure Runbook PowerShell script that stores a file from SharePoint using Get-PnPFile and then stores it in an Azure Storage Container. Generally this works. The way I understand it is that in my runbook, when I run Get-PnPFile the file is stored on a virtual runbook-local drive. Some file types however don't seem to be stored, such as:
- exe
- zip
- txt
- rtf
- dotx
- thmx
Now .exe I could understand, but not the rest.
The error message is (when it tries to upload the file to Azure Storage):
Set-AzStorageBlobContent : Can not find the specified file 'C:\Temp\qkamwig5.crx\2022.1.5\sites\abc\Documents IT Service\Template-CH-DE.rtf'.
At line:151 char:13
+ Set-AzStorageBlobContent -Container $container -File $fil ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-AzStorageBlobContent], ArgumentException
+ FullyQualifiedErrorId : ArgumentException,Microsoft.WindowsAzure.Commands.Storage.Blob.SetAzureBlobContentCommand
Here's an excerpt from my script, where the download and upload happen:
try
{
#Download file
Get-PnPFile -Url $File.ServerRelativeUrl -Path $fileDownLoadPath -FileName $File.Name -AsFile
"Downloading file, Path: " + $fileDownLoadPath + " , File: " + $File.Name
#Upload file to storage
$container = "backups-testing";
$filepath = $fileDownLoadPath + "\" + $File.Name
"filepath:" + $filepath
Set-AzStorageBlobContent -Container $container -File $filepath -Blob $filepath -Force
#Delete temp file
Remove-Item $filepath
}
catch
{
$global:errorHappened = $true;
"An error happened in GetFolderFilesRecursively()"
$global:errorMessages.Add($error.Exception.Message + "`n");
$error.Exception.Message;
}
Is it known that these file types cannot be stored on that local temp storage or do you think the issue is something else?