Uppload files to SharePoint list using PowerShell in Azure Automation (over Azure Application or other way)

Mountain Pond 1,576 Reputation points
2023-11-24T22:04:30.2566667+00:00

Hello,

Can I indicate the scope to which these permissions apply?

msedge_QFs8CWOePT

Basically all I need is to allow the application to add files to one library on SharePoint.

I will describe it in full. A script that runs in Azure Automation (in Powershell) connects to a third-party site and downloads a file.I would like it to upload files to SharePoint. However, I don't want to create a separate user with an o365 license just for this task.

I could use a SharePoint share link and give access to the user without a license. But I think it will be even more difficult because of the second factor and modern authentication. OR I could use the app, but apparently I can't limit it to just one site and one library.

There may be a more convenient way, but I don't know about it.

Thank you.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,366 questions
Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2023-11-27T02:42:06.71+00:00

    Hi @Mountain Pond,

    You could use Add-PnPFile cmdlet to upload file to SharePoint Online

    Add-PnPFile -Folder "Shared Documents/General" -Path $SourceDocument
    

    For detail steps you could refer to following article

    https://practical365.com/azure-automation-spo-create-files/


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.