如何通过 Azure 自动化中的 Powershell Runbook 在 SSAS 中执行 DMV 查询?

问题描述

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

我已经编写并测试了一个 powershell 脚本,它似乎在我的本地机器工作正常,但是当我在云上运行相同的脚本时 作为一个蔚蓝的运行手册,似乎不可能打开一个连接。

我用这个代码打开了与ssas的连接:

 $connectionString = "Provider=msolap; Data Source=asazure://westeurope.asazure.windows.net/servername;User Id={0};Password={1}; Initial Catalog=DataModel" -f $ssasUser,$ssasPassword;
    
 ## Connect to the data source and open SSAS
 $connection = New-Object System.Data.OleDb.OleDbConnection $connectionString
 $connection.open()

我似乎无法打开连接,当我运行此代码时,我收到以下错误

 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."

在网上搜索,我找到的唯一解决方案似乎是简单地下载并安装 mdac sdk,但在云上运行时无法做到这一点。

我需要帮助来修复错误或找到替代解决方。 谢谢。

解决方法

由于连接字符串中的源是 asazure,所以我假设它是 Azure 分析服务器,因此我建议您按照说明在 Azure 自动化帐户中导入 SqlServer 模块 here,然后使用 {{3}运行手册中的 cmdlet。

相关参考资料: