Hi @Daniel Maier ,
1.We can copy documents from SharePoint Online to Azure Blob Storage using Power Automate. There is a template in Power Automate called "Copy files from a SharePoint folder to a AzureBlob folder", which can copy from a shared folder in SharePoint Online to Azure storage by executing a simple flow.
2.This PowerShell script shows how to download and sync documents in a SharePoint Document Library into an Azure Storage Container using CLI for Microsoft 365 and Azure CLI commands.
$spolHostName = "https://tenant-name.sharepoint.com"
$spolSiteRelativeUrl = "/sites/site-name"
$spolDocLibTitle = "document-library-title"
$azStorageAccountKey = "*****************"
$azStorageAccountName = "azure-storage-account-name"
$azStorageContainerName = "azure-storage-container-name"
$localBaseFolderName = "local-base-folder-name"
$localFileDownloadFolderPath = $PSScriptRoot
$spolSiteUrl = $spolHostName + $spolSiteRelativeUrl
$spolLibItems = m365 spo listitem list --webUrl $spolSiteUrl --title
$spolDocLibTitle --fields 'FileRef,FileLeafRef' --filter "FSObjType eq 0" -o json | ConvertFrom-Json
if ($spolLibItems.Count -gt 0) {
ForEach ($spolLibItem in $spolLibItems) {
$spolLibFileRelativeUrl = $spolLibItem.FileRef
$spolFileName = $spolLibItem.FileLeafRef
$spolLibFolderRelativeUrl = $spolLibFileRelativeUrl.Substring(0, $spolLibFileRelativeUrl.lastIndexOf('/'))
$localDownloadFolderPath = Join-Path $localFileDownloadFolderPath $localBaseFolderName $spolLibFolderRelativeUrl
If (!(test-path $localDownloadFolderPath)) {
$message = "Target local folder $localDownloadFolderPath not exist"
Write-Host $message -ForegroundColor Yellow
New-Item -ItemType Directory -Force -Path $localDownloadFolderPath | Out-Null
$message = "Created target local folder at $localDownloadFolderPath"
Write-Host $message -ForegroundColor Green
}
else {
$message = "Target local folder exist at $localDownloadFolderPath"
Write-Host $message -ForegroundColor Blue
}
$localFilePath = Join-Path $localDownloadFolderPath $spolFileName
$message = "Processing SharePoint file $spolFileName"
Write-Host $message -ForegroundColor Green
m365 spo file get --webUrl $spolSiteUrl --url $spolLibFileRelativeUrl --asFile --path $localFilePath
$message = "Downloaded SharePoint file at $localFilePath"
Write-Host $message -ForegroundColor Green
}
$localFolderToSync = Join-Path $localFileDownloadFolderPath
$localBaseFolderName
az storage blob sync --account-key $azStorageAccountKey --account-name $azStorageAccountName -c $azStorageContainerName -s $localFolderToSync --only-show-errors | Out-Null
$message = "Syncing local folder $localFolderToSync with Azure Storage Container $azStorageContainerName is completed"
Write-Host $message -ForegroundColor Green
}
else {
Write-Host "No files in $spolDocLibTitle library" -ForegroundColor Yellow
}
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.