0

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?

Seth
  • 1,215
  • 15
  • 35
Mike
  • 1
  • Just going by your code your file will be stored in whatever `$fileDownLoadPath` is pointing to. The error indicates the file could not be found in that location. Did you try to make an explicit check beforehand? If you look at the [documented](https://learn.microsoft.com/en-us/azure/automation/automation-runbook-execution#temporary-storage-in-a-sandbox) limitations it should only be capped at 1 GB. As that part metions Workflows can complicate things. Naturally Defender might just snatch those files but no idea where that would show up. – Seth Jan 05 '22 at 11:34
  • 1
    Yes, the downloadpath looks like this 'C:\Temp\qkamwig5.crx\2022.1.5\sites\abc\Documents IT Service\Template-CH-DE.rtf' and I only get the error message for the file extensions mentioned above. I don't explicitly check for existence, I can try, but I'm pretty sure I will get the same result and the file is not downloaded in the first place. – Mike Jan 05 '22 at 15:11

0 Answers0