如何通过Azure Automation的powershell runbook在SSAS中执行DMV查询



我正试图打开与ssas服务器连接,并执行dmv查询以便通过powershell runbookAzure Automation帐户提取表元数据。

我已经编写并测试了一个powershell脚本,该脚本在我的本地机器上运行良好,但当我在云上运行与azure runbook相同的脚本时,似乎不可能打开连接。

我使用代码打开了与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 Analysis服务器,因此我建议您在Azure Automation帐户中导入SqlServer模块,如此处所述,然后在runbook中使用Invoke-ASCmd cmdlet。

相关参考文献:

  • https://www.sqlshack.com/azure-automation-automate-pause-and-resume-of-azure-analysis-services/
  • https://techcommunity.microsoft.com/t5/sql-server-support/automating-azure-analysis-service-processing-using-azure/ba-p/319006
  • https://cloudblogs.microsoft.com/industry-blog/en-gb/technetuk/2018/06/22/how-to-automate-processing-your-azure-analysis-services-models/
  • https://jorgklein.com/2017/02/02/process-azure-analysis-services-databases-from-azure-automation/
  • https://learn.microsoft.com/en-us/dotnet/api/system.data.oledb.oledbconnection?view=dotnet-平台-ext-5.0
  • https://www.powershellgallery.com/packages/OledbSql/1.0.4

最新更新