使用 Azure 功能备份 Sharepoint Online

Backup Sharepoint Online with Azure functions

有没有办法使用 azure 函数在线生成共享点备份?

我已经使用托管身份对租户进行了身份验证

想法是下载文档中的所有文件并将它们上传到一个 Azure 存储帐户

我使用了这段代码,但出现错误:

using namespace System.Net

param($Request, $TriggerMetadata)
   
$TenantSiteURL = "https://tenant.sharepoint.com"
$SiteRelativeURL = "/sites/BackupSource"
$LibraryName = "Documenti Condivisi"
$DownloadPath ="\Temp\Docs"

#Connect-PnPOnline -ManagedIdentity 
Connect-PnPOnline -Url $TenantSiteURL -ManagedIdentity
Write-Warning "Connesso"
#Set-Location -Path SPO:$SiteRelativeURL

Get-PnPMicrosoft365Group

Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
    StatusCode = [HttpStatusCode]::OK
})


2022-01-03T16:58:32.983 [Information] Executing 'Functions.HttpTrigger1' (Reason='This function was programmatically called via the host APIs.', Id=09c1fe95-6b6e-4e85-8c8f-815e37e99d04)
2022-01-03T16:58:40.915 [Information] OUTPUT:
2022-01-03T16:58:41.541 [Information] OUTPUT: Account   SubscriptionName TenantId                             Environment
2022-01-03T16:58:41.542 [Information] OUTPUT: -------   ---------------- --------                             -----------
2022-01-03T16:58:41.549 [Information] OUTPUT: MSI@50342                  --- AzureCloud
2022-01-03T16:58:41.549 [Information] OUTPUT:
2022-01-03T16:58:43.530 [Error] ERROR: Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.Exception             :Type              : System.Management.Automation.ParameterBindingExceptionMessage           : Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.ErrorId           : AmbiguousParameterSetLine              : 13Offset            : 1CommandInvocation :MyCommand        : Connect-PnPOnlineBoundParameters  :Comparer : System.OrdinalIgnoreCaseComparerCount    : 2Keys     :Length : 3Length : 15Values   :Length : 30IsPresent : TrueSyncRoot :Comparer : System.OrdinalIgnoreCaseComparerCount    : 2Keys     :Length : 3Length : 15Values   :Length : 30IsPresent : TrueSyncRoot :Comparer : System.OrdinalIgnoreCaseComparerCount    : 2Keys     :Length : 3Length : 15Values   :Length : 30IsPresent : TrueSyncRoot :Comparer : System.OrdinalIgnoreCaseComparerCount    : 2Keys     :Length : 3Length : 15Values   :Length : 30IsPresent : TrueSyncRoot :Comparer : System.OrdinalIgnoreCaseComparerCount    : 2Keys     :Length : 3Length : 15Values   :Length : 30IsPresent : TrueSyncRoot :Comparer : System.OrdinalIgnoreCaseComparerCount    : 2Keys     :Length : 3Length : 15Values   :Length : 30IsPresent : TrueSyncRoot :Comparer : System.OrdinalIgnoreCaseComparerCount    : 2Keys     : …Values   : …SyncRoot : …ScriptLineNumber : 13OffsetInLine     : 1HistoryId        : 1ScriptName       : C:\home\site\wwwroot\HttpTrigger1\run.ps1Line             : Connect-PnPOnline -Url $TenantSiteURL -ManagedIdentityPositionMessage  : At C:\home\site\wwwroot\HttpTrigger1\run.ps1:13 char:1+ Connect-PnPOnline -Url $TenantSiteURL -ManagedIdentity+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot     : C:\home\site\wwwroot\HttpTrigger1PSCommandPath    : C:\home\site\wwwroot\HttpTrigger1\run.ps1InvocationName   : Connect-PnPOnlinePipelineLength   : 1PipelinePosition : 1CommandOrigin    : InternalErrorRecord       :Exception             :Type    : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.HResult : -2146233087CategoryInfo          : InvalidArgument: (:) [Connect-PnPOnline], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : AmbiguousParameterSet,PnP.PowerShell.Commands.Base.ConnectOnlineInvocationInfo        :MyCommand        : Connect-PnPOnlineScriptLineNumber : 13OffsetInLine     : 1HistoryId        : 1ScriptName       : C:\home\site\wwwroot\HttpTrigger1\run.ps1Line             : Connect-PnPOnline -Url $TenantSiteURL -ManagedIdentityPositionMessage  : At C:\home\site\wwwroot\HttpTrigger1\run.ps1:13 char:1+ Connect-PnPOnline -Url $TenantSiteURL -ManagedIdentity+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot     : C:\home\site\wwwroot\HttpTrigger1PSCommandPath    : C:\home\site\wwwroot\HttpTrigger1\run.ps1CommandOrigin    : InternalScriptStackTrace      : at <ScriptBlock>, C:\home\site\wwwroot\HttpTrigger1\run.ps1: line 13TargetSite        :Name          : ThrowAmbiguousParameterSetExceptionDeclaringType : System.Management.Automation.CmdletParameterBinderController, System.Management.Automation, Version=7.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType    : MethodModule        : System.Management.Automation.dllStackTrace        :at System.Management.Automation.CmdletParameterBinderController.ThrowAmbiguousParameterSetException(UInt32 parameterSetFlags, MergedCommandParameterMetadata bindableParameters)at System.Management.Automation.CmdletParameterBinderController.ValidateParameterSets(Boolean prePipelineInput, Boolean setDefault)at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)at System.Management.Automation.CommandProcessor.BindCommandLineParameters()at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)--- End of stack trace from previous location where exception was thrown ---at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)Data              : System.Collections.ListDictionaryInternalSource            : System.Management.AutomationHResult           : -2146233087CategoryInfo          : InvalidArgument: (:) [Connect-PnPOnline], ParameterBindingExceptionFullyQualifiedErrorId : AmbiguousParameterSet,PnP.PowerShell.Commands.Base.ConnectOnlineInvocationInfo        :MyCommand        : Connect-PnPOnlineScriptLineNumber : 13OffsetInLine     : 1HistoryId        : 1ScriptName       : C:\home\site\wwwroot\HttpTrigger1\run.ps1Line             : Connect-PnPOnline -Url $TenantSiteURL -ManagedIdentityPositionMessage  : At C:\home\site\wwwroot\HttpTrigger1\run.ps1:13 char:1+ Connect-PnPOnline -Url $TenantSiteURL -ManagedIdentity+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot     : C:\home\site\wwwroot\HttpTrigger1PSCommandPath    : C:\home\site\wwwroot\HttpTrigger1\run.ps1CommandOrigin    : InternalScriptStackTrace      : at <ScriptBlock>, C:\home\site\wwwroot\HttpTrigger1\run.ps1: line 13Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: ERROR: Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.Exception             :Type              : System.Management.Automation.ParameterBindingExceptionMessage           : Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.ErrorId           : AmbiguousParameterSetLine              : 13Offset            : 1CommandInvocation :MyCommand        : Connect-PnPOnlineBoundParameters  :Comparer : System.OrdinalIgnoreCaseComparerCount    : 2Keys     :Length : 3Length : 15Values   :Length : 30IsPresent : TrueSyncRoot :Comparer : System.OrdinalIgnoreCaseComparerCount    : 2Keys     :Length : 3Length : 15Values   :Length : 30IsPresent : TrueSyncRoot :Comparer : System.OrdinalIgnoreCaseComparerCount    : 2Keys     :Length : 3Length : 15Values   :Length : 30IsPresent : TrueSyncRoot :Comparer : System.OrdinalIgnoreCaseComparerCount    : 2Keys     :Length : 3Length : 15Values   :Length : 30IsPresent : TrueSyncRoot :Comparer : System.OrdinalIgnoreCaseComparerCount    : 2Keys     :Length : 3Length : 15Values   :Length : 30IsPresent : TrueSyncRoot :Comparer : System.OrdinalIgnoreCaseComparerCount    : 2Keys     :Length : 3Length : 15Values   :Length : 30IsPresent : TrueSyncRoot :Comparer : System.OrdinalIgnoreCaseComparerCount    : 2Keys     : …Values   : …SyncRoot : …ScriptLineNumber : 13OffsetInLine     : 1HistoryId        : 1ScriptName       : C:\home\site\wwwroot\HttpTrigger1\run.ps1Line             : Connect-PnPOnline -Url $TenantSiteURL -ManagedIdentityPositionMessage  : At C:\home\site\wwwroot\HttpTrigger1\run.ps1:13 char:1+ Connect-PnPOnline -Url $TenantSiteURL -ManagedIdentity+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot     : C:\home\site\wwwroot\HttpTrigger1PSCommandPath    : C:\home\site\wwwroot\HttpTrigger1\run.ps1InvocationName   : Connect-PnPOnlinePipelineLength   : 1PipelinePosition : 1CommandOrigin    : InternalErrorRecord       :Exception             :Type    : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.HResult : -2146233087CategoryInfo          : InvalidArgument: (:) [Connect-PnPOnline], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : AmbiguousParameterSet,PnP.PowerShell.Commands.Base.ConnectOnlineInvocationInfo        :MyCommand        : Connect-PnPOnlineScriptLineNumber : 13OffsetInLine     : 1HistoryId        : 1ScriptName       : C:\home\site\wwwroot\HttpTrigger1\run.ps1Line             : Connect-PnPOnline -Url $TenantSiteURL -ManagedIdentityPositionMessage  : At C:\home\site\wwwroot\HttpTrigger1\run.ps1:13 char:1+ Connect-PnPOnline -Url $TenantSiteURL -ManagedIdentity+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot     : C:\home\site\wwwroot\HttpTrigger1PSCommandPath    : C:\home\site\wwwroot\HttpTrigger1\run.ps1CommandOrigin    : InternalScriptStackTrace      : at <ScriptBlock>, C:\home\site\wwwroot\HttpTrigger1\run.ps1: line 13TargetSite        :Name          : ThrowAmbiguousParameterSetExceptionDeclaringType : System.Management.Automation.CmdletParameterBinderController, System.Management.Automation, Version=7.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType    : MethodModule        : System.Management.Automation.dllStackTrace        :at System.Management.Automation.CmdletParameterBinderController.ThrowAmbiguousParameterSetException(UInt32 parameterSetFlags, MergedCommandParameterMetadata bindableParameters)at System.Management.Automation.CmdletParameterBinderController.ValidateParameterSets(Boolean prePipelineInput, Boolean setDefault)at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)at System.Management.Automation.CommandProcessor.BindCommandLineParameters()at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)--- End of stack trace from previous location where exception was thrown ---at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)Data              : System.Collections.ListDictionaryInternalSource            : System.Management.AutomationHResult           : -2146233087CategoryInfo          : InvalidArgument: (:) [Connect-PnPOnline], ParameterBindingExceptionFullyQualifiedErrorId : AmbiguousParameterSet,PnP.PowerShell.Commands.Base.ConnectOnlineInvocationInfo        :MyCommand        : Connect-PnPOnlineScriptLineNumber : 13OffsetInLine     : 1HistoryId        : 1ScriptName       : C:\home\site\wwwroot\HttpTrigger1\run.ps1Line             : Connect-PnPOnline -Url $TenantSiteURL -ManagedIdentityPositionMessage  : At C:\home\site\wwwroot\HttpTrigger1\run.ps1:13 char:1+ Connect-PnPOnline -Url $TenantSiteURL -ManagedIdentity+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot     : C:\home\site\wwwroot\HttpTrigger1PSCommandPath    : C:\home\site\wwwroot\HttpTrigger1\run.ps1CommandOrigin    : InternalScriptStackTrace      : at <ScriptBlock>, C:\home\site\wwwroot\HttpTrigger1\run.ps1: line 13Exception: Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.Stack:    at System.Management.Automation.CmdletParameterBinderController.ThrowAmbiguousParameterSetException(UInt32 parameterSetFlags, MergedCommandParameterMetadata bindableParameters)at System.Management.Automation.CmdletParameterBinderController.ValidateParameterSets(Boolean prePipelineInput, Boolean setDefault)at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)at System.Management.Automation.CommandProcessor.BindCommandLineParameters()at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)--- End of stack trace from previous location where exception was thrown ---at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2022-01-03T16:58:43.540 [Warning] WARNING: Connesso
2022-01-03T16:58:43.657 [Error] ERROR: There is currently no connection yet. Use Connect-PnPOnline to connect.

SharePoint Online 中没有可用于备份和还原的 PowerShell 命令。

SharePoint 在线备份解决方案here

您可以使用 MABS 备份 SharePoint 在线 Azure。参考 here