gpt4 book ai didi

Azure PowerShell Runbook 不支持 System.Data.OleDb.OleDbConnection

转载 作者:行者123 更新时间:2023-12-03 06:50:30 26 4
gpt4 key购买 nike

我正在尝试打开与 ssas 服务器的连接并执行 dax 查询,以便通过 Azure 自动化帐户中的 powershell Runbook 提取表元数据。

$daxConnectionString = "Provider=MSOLAP;数据源=..."

我使用以下代码:

$daxConnectionString = "Provider=MSOLAP;Data Source=$daxServer;Initial Catalog=$daxCatalog;UID=$daxUserId;PWD=$daxPwd"
$daxConnection = New-Object -TypeName System.Data.OleDb.OleDbConnection
$daxConnection.ConnectionString = $daxConnectionString
$daxConnection.Open()
$daxCommand = $daxConnection.CreateCommand()

系统返回以下异常:

System.Management.Automation.MethodInvocationException: Exception calling "Open" with "0" argument(s): "The .Net Framework Data Providers require Microsoft Data Access Components(MDAC).  Please install Microsoft Data Access Components(MDAC) version 2.6 or later." ---> System.InvalidOperationException: The .Net Framework Data Providers require Microsoft Data Access Components(MDAC).  Please install Microsoft Data Access Components(MDAC) version 2.6 or later. ---> System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {2206CDB2-19C1-11D1-89E0-00C04FD7A829} failed due to the following error: 800736b1 The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail. (Exception from HRESULT: 0x800736B1).

是否有可用的 MDAC 模块或者我可以通过其他方式解决此问题吗?

提前致谢,巴特

最佳答案

连接到分析服务器。我没有使用基于 MSOLAP 提供程序的连接,而是基于 ADOMD 客户端

daxConnectionString = "Data Source=$daxServer;Initial Catalog=$daxCatalog;User ID=$daxUserId;Password=$daxPwd"
$daxConnection = New-Object Microsoft.AnalysisServices.AdomdClient.AdomdConnection
$daxConnection.ConnectionString = $daxConnectionString
$daxConnection.Open()
$daxCommand = $daxConnection.CreateCommand()

完成此操作后,可以像这样填充数据集:

 $daxAdapter = New-Object -TypeName Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter $daxCommand
$daxDataset = New-Object -TypeName System.Data.DataSet
$daxCommand.CommandText = $query
$nrRows = $daxAdapter.Fill($daxDataset)

唯一的问题是 AdomdClient 在 RunBook 中不可用,在模块中也不可用...我们创建自己的...

  • 从以下位置下载 nuget 包:Nuget.org
  • 将包扩展名重命名为 .zip
  • 在包内搜索名为 Microsoft.AnalysisServices.AdomdClient 的 DLL
  • 复制 Microsoft.AnalysisServices.AdomdClient.dll 文件并将其粘贴到新文件夹中。
  • 右键单击该文件夹并将其发送至 zip。
  • 通过“添加模块”将 zip 文件添加到 Runbook 模块

确保在 RunBook 中通过以下方式加载库:

$assemblyPath = "C:\Modules\User\Microsoft.AnalysisServices.AdomdClient\Microsoft.AnalysisServices.AdomdClient.dll"
try {Add-Type -Path $assemblyPath}
catch { $_.Exception.LoaderExceptions }

enter image description here

关于Azure PowerShell Runbook 不支持 System.Data.OleDb.OleDbConnection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73718407/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com