1
votes

In AZURE ANALYSIS SERVICES Tabular model (with compatibility level 1400) I imported a Blob storage account as a Data Source. It's Authentication Kind is Key kind of authentication. The key is a Static Key.

But while refreshing the Tabular using a Runbook in Automation Account (Cloud PowerShell) is there a way to pass the key/credentials so that it could authenticate?

Otherwise the PowerShell fails with below message

The given credential is missing a required property. Data source kind: AzureBlobs. Authentication kind: Key. Property name: Key. The exception was raised by the IDbConnection interface.

Here is the Source definition copied from Model.bim file:

 {
  "createOrReplace": {
    "object": {
      "database": "azureanalysisservicesdatabase",
      "dataSource": "OMSLogs"
    },
    "dataSource": {
      "type": "structured",
      "name": "OMSLogs",
      "connectionDetails": {
        "protocol": "azure-blobs",
        "address": {
          "account": "storage",
          "domain": "blob.core.windows.net"
        },
        "authentication": null,
        "query": null
      },
      "credential": {
        "AuthenticationKind": "Key",
        "kind": "AzureBlobs",
        "path": "https://storage.blob.core.windows.net/",
        "PrivacySetting": "Organizational"
      }
    }
  }
}

this is the code I ran in PowerShell to process the Database:

Invoke-ProcessASDatabase -databasename $DatabaseName -server $AnalysisServerName -RefreshType "Full" -Credential $SPCredential
1

1 Answers

1
votes

Okay I also hit a similar issue and found the solution, add "Key" to the "credential" object:

"credential": {
    "AuthenticationKind": "Key",
    "kind": "AzureBlobs",
    "path": "https://storage.blob.core.windows.net/",
    "PrivacySetting": "Organizational",
    "Key": "<StorageAccountKey>"
  }

This isn't well documented by Microsoft, but this worked for me

Update with PowerShell sample:

Get-ChildItem -Filter "drop" -Recurse -Path $sourcePath -Directory | 
Get-ChildItem -recurse -filter *.asdatabase -file | ForEach-Object {
    $filename = $_.fullname
    $generatedFile = $buildPath + $_.BaseName + ".xmla"
    "Processing $filename"
    & $deploymentWizard $filename /o:$generatedFile

    # Have to add Blob Key now, as Deployment Wizard doesn't like 
    # adding the Key (bug maybe? Or DeloyWizard isn't up to date)
    $file = Get-Content $generatedFile -Raw | ConvertFrom-Json        
    $file.createOrReplace.database.model.dataSources | ForEach-Object {
        # Add Blob Key to credential object
        if ($_.name.StartsWith("AzureBlobs/")) {           
            $_.credential | Add-Member -Name "Key" -Value $storageKey -MemberType NoteProperty -Force
        }
    }
    $file = $file | ConvertTo-Json -Depth 32
    $file | Set-Content -Path $generatedFile -Encoding utf8
}