我正在尝试使用 Azure Runbooks 使用 Power Shell TMSL 脚本刷新 Azure 上托管的 SSAS 表格多维数据集.
failed: {"database":"DashboardName","table":"table Name,"partition":"table-CurrentMonth"} - Non-static method requires a target. at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
at Microsoft.AnalysisServices.AadAuthenticator.BuildAadTokenHolderFromAuthenticationResult(Object result, AadAuthParams authParams, String dataSource, Boolean useAdalCache)
at Microsoft.AnalysisServices.AadAuthenticator.ReAcquireToken(String refreshToken, AadAuthParams authParams, String dataSource, Boolean useAdalCache)
at Microsoft.AnalysisServices.AadTokenHolder.GetValidAccessToken()
at Microsoft.AnalysisServices.HttpStream.GetRequestStream(Boolean isNewXmlaRequest)
at Microsoft.AnalysisServices.HttpStream.WaitForAndUpdateHttpResponseContainingXmlaPayload()
at Microsoft.AnalysisServices.HttpStream.GetResponseStream()
at Microsoft.AnalysisServices.HttpStream.GetResponseDataType()
at Microsoft.AnalysisServices.CompressedStream.GetResponseDataType()
at Microsoft.AnalysisServices.XmlaClient.EndRequest(Boolean useBinaryXml)
at Microsoft.AnalysisServices.XmlaClient.SendExecuteAndReadResponse(Boolean skipResults, Boolean throwIfError, Boolean useBinaryXml)
at Microsoft.AnalysisServices.Core.AnalysisServicesClient.Execute(String command)
at Microsoft.AnalysisServices.Core.Server.Execute(String command)
at Microsoft.AnalysisServices.PowerShell.Cmdlets.ExecuteScriptCommand.ExecuteQueryBatch(Server server, String queryStatement)
at Microsoft.AnalysisServices.PowerShell.Cmdlets.ExecuteScriptCommand.ExecuteQueryBatches(Server server)
at Microsoft.AnalysisServices.PowerShell.Cmdlets.ExecuteScriptCommand.ExecuteQuery()
at Microsoft.AnalysisServices.PowerShell.Cmdlets.ExecuteScriptCommand.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
用于刷新的脚本是
$Credential = Get-AutomationPSCredential -Name 'XXXX'
$Objects = @(
'{"database":"Database Name","table":"tableName","partition":"CurrentMonth"}',
'{"database":"Database Name","table":"tableName","partition":"CurrentMonth"}',
'{"database":"Database Name","table":"tableName"}',
'{"database":"Database Name","table":"tableName"}'
)
$QueryPrefix = '{"refresh":{"type":"full","objects":['
$QuerySuffix = ']}}'
for ($i = 0; $i -lt $Objects.Count ; $i++) {
Sleep -s 5
$Query = $QueryPrefix + $Objects[$i] + $QuerySuffix
Invoke-ASCmd -Server "ServerName" -Database "DatabaseName" -Credential $Credential -Query $Query -ConnectionTimeout 0 -QueryTimeout 0
}