我有一个SSIS包连接,连接到Sharepoint站点w/ a UNC路径,如下所示:
\\[Site URL]\DavWWWRoot\sites\DTS_BURM\DARBenchmarks\FileName.csv
我的包读取文件并将其导入到SQL中。这个过程在VS中工作得很好。但是,如果我想在作业中从Server代理运行包,它将向我提供以下错误:
URL\DavWWWRoot\sites\DTS_BURM\DARBenchmarks\FileName.csv".导入原始数据:
:无法打开“”站点
起初,这对我来说是很明显的。运行SQL作业的帐户无权访问SharePoint。因此,我向凭据文件夹添加了一个Service帐户,然后使用这些凭据为Server代理创建代理。此外,我还将该服务帐户作为所有者添加到SharePoint中,以便它具有读/写权限。
即使在这一切之后,我仍然收到一个错误,说明它“无法打开数据文件”。我不知道我还能做些什么,如果有人有建议,我会非常感激的。
发布于 2020-08-27 12:45:27
正如我在评论中提到的那样,当部署到服务器时,我们在使用SharePoint UNC和SSIS方面没有太大的运气或稳定性。最后,我们在代理作业步骤中使用一个PowerShell脚本在SSIS步骤之前下载本地文件。
这只适用于Server 2014或更高版本,因为代理使用的PowerShell版本和需要安装SharePoint模块。
您将需要SQL服务器的管理权限,或者谁来管理它,以便以Administrator.的形式登录并运行PowerShell
然后,
安装-模块SharePointPnPPowerShellOnline
Net.ServicePointManager::SecurityProtocol =Net.SecurityProtocolType::Tls12
然后,
一旦您完成了该操作,我们将专门为此设置一个服务帐户,并发现该帐户需要与您正在下载文件的SharePoint站点的“站点所有者”组分开。
然后使用以下代码添加PowerShell代理作业步骤,以下载SSIS的本地文件。更新您的环境。
$SharepointBaseURL = "https://yoursharepoint.com/sites/sitename/" #base URL of your site
$SharepointDocumentFolder = "Shared Documents/path to folder" #path to the folder where the files are located
$LocalShare = "\\server\localshare" #where you download local, sql proxy account needs access
$un = "YourAccount@domain.com"
$pw = "Password"
Set-Location "c:\" #we had to have this when running in agent job
try
{
$sp = $pw | ConvertTo-SecureString -AsPlainText -Force
$plainCred = New-Object system.management.automation.pscredential -ArgumentList $un, $sp
Connect-PnPOnline -Url $SharepointBaseURL -Credentials $plainCred -ErrorAction Stop
$SharePointFileList = Get-PnPFolderItem -FolderSiteRelativeUrl $SharepointDocumentFolder -ItemType File #gets a list of all files in the sharepoint directory
foreach ($File in $SharePointFileList)
{
Get-PnPFile -Url $File.ServerRelativeUrl -Path $LocalShare -Filename $File.Name -AsFile -ErrorAction Stop #Add "-Force" parameter if you want to override if the file already exists
}
}
Catch
{
Throw $_.Exception.Message #any errors/exceptions this bubbles it out into job history
}
然后,SSIS被配置为访问本地文件。
https://stackoverflow.com/questions/63619096
复制相似问题