首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >SSIS:通过Server代理作业访问Sharepoint UNC

SSIS:通过Server代理作业访问Sharepoint UNC
EN

Stack Overflow用户
提问于 2020-08-27 15:15:24
回答 1查看 537关注 0票数 0

我有一个SSIS包连接,连接到Sharepoint站点w/ a UNC路径,如下所示:

代码语言:javascript
代码运行次数:0
运行
复制
\\[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中,以便它具有读/写权限。

即使在这一切之后,我仍然收到一个错误,说明它“无法打开数据文件”。我不知道我还能做些什么,如果有人有建议,我会非常感激的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-27 20:45:27

正如我在评论中提到的那样,当部署到服务器时,我们在使用SharePoint UNC和SSIS方面没有太大的运气或稳定性。最后,我们在代理作业步骤中使用一个PowerShell脚本在SSIS步骤之前下载本地文件。

这只适用于Server 2014或更高版本,因为代理使用的PowerShell版本和需要安装SharePoint模块。

您将需要SQL服务器的管理权限,或者谁来管理它,以便以Administrator.的形式登录并运行PowerShell

然后,

  1. 以“是”的形式运行以下命令,对任何提示:

安装-模块SharePointPnPPowerShellOnline

  1. 如果在连接关闭或无法通信的情况下运行该命令时出错,则可能与PowerShell中未启用的Tls12相关。运行以下命令以启用Tls12协议:

Net.ServicePointManager::SecurityProtocol =Net.SecurityProtocolType::Tls12

然后,

  1. 重新运行“安装模块SharePointPnPPowerShellOnline”,它现在应该成功了。

一旦您完成了该操作,我们将专门为此设置一个服务帐户,并发现该帐户需要与您正在下载文件的SharePoint站点的“站点所有者”组分开。

然后使用以下代码添加PowerShell代理作业步骤,以下载SSIS的本地文件。更新您的环境。

代码语言:javascript
代码运行次数:0
运行
复制
$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被配置为访问本地文件。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63619096

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档