0
votes

I am running below code from my automation runbook to refresh analysis service models:

Add-AzureAnalysisServicesAccount -RolloutEnvironment $RolloutEnvironment -ServicePrincipal -Credential $_Credential -TenantId $TenantId 

Write-output ("Refreshing Analysis Server mode $DatabaseName...")
# Perform a Process Full on the Azure Analysis Services database
Invoke-ProcessASDatabase -Server $Server -DatabaseName $DatabaseName -RefreshType Full -ServicePrincipal -Credential $_Credential 

I am getting following error while running model refresh from azure automation account:

Invoke-ProcessASDatabase : Failed to save modifications to the server. Error returned: 'The given credential is missing a required property. Data source kind: SQL. Authentication kind: OAuth2. Property name: AccessToken. The exception was raised by the IDbConnection interface. Technical Details: RootActivityId: ad01e91e-a17f-4b69-8e1d-ad2f18ddbdeb Date (UTC): 12/30/2019 9:59:09 AM '. At line:24 char:1 + Invoke-ProcessASDatabase -Server $Server -DatabaseName $DatabaseName ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (DevOps:String) [Invoke-ProcessASDatabase], OperationException + FullyQualifiedErrorId : Microsoft.AnalysisServices.PowerShell.Cmdlets.ProcessASDatabase

2

2 Answers

0
votes

I think this doc - Refresh with Azure Automation is clear enough, please follow it to have a try. Make sure the service principal you created has server administrator permissions on the server and create a Credential in the runbook to store it.

Sample script:

param
(
    [Parameter (Mandatory = $false)]
    [object] $WebhookData,

    [Parameter (Mandatory = $false)]
    [String] $DatabaseName,
    [Parameter (Mandatory = $false)]
    [String] $AnalysisServer,
    [Parameter (Mandatory = $false)]
    [String] $RefreshType
)

$_Credential = Get-AutomationPSCredential -Name "ServicePrincipal"

# If runbook was called from Webhook, WebhookData will not be null.
if ($WebhookData)
{ 
    # Retrieve AAS details from Webhook request body
    $atmParameters = (ConvertFrom-Json -InputObject $WebhookData.RequestBody)
    Write-Output "CredentialName: $($atmParameters.CredentialName)"
    Write-Output "AnalysisServicesDatabaseName: $($atmParameters.AnalysisServicesDatabaseName)"
    Write-Output "AnalysisServicesServer: $($atmParameters.AnalysisServicesServer)"
    Write-Output "DatabaseRefreshType: $($atmParameters.DatabaseRefreshType)"

    $_databaseName = $atmParameters.AnalysisServicesDatabaseName
    $_analysisServer = $atmParameters.AnalysisServicesServer
    $_refreshType = $atmParameters.DatabaseRefreshType

    Invoke-ProcessASDatabase -DatabaseName $_databaseName -RefreshType $_refreshType -Server $_analysisServer -ServicePrincipal -Credential $_credential
}
else 
{
    Invoke-ProcessASDatabase -DatabaseName $DatabaseName -RefreshType $RefreshType -Server $AnalysisServer -ServicePrincipal -Credential $_Credential
}
0
votes

It is not your problem and I don't see any issue with your code above. I can recreate the issue in Azure all the time. The problem is when you deploy with Azure CICD and do not deploy within Visual Studio.

There are 2 plugins/extension in the Visual Studio Marketplace that will deploy AAS models to Azure. They both report successful deployments, but when you issue the runbook, you get the error you see. If you immediatley then go and deploy with Visual Studio and run the Runbook, the error goes away.

I've been working with the developers of both extensions and it seems to be unstable.