0
votes

We are deploying Tabular SSAS instance as part of on-premise azure build and release pipeline, using Microsoft.AnalysisServices.Deployment.exe with .asdatabase file.

I am trying to figure out a way to update (relational DB) data source connection string during the release stage.

Most of the solutions I could find use SSIS, which we don't, so I would strongly prefer not to introduce it for this task.

I can see that connections are defined in .asdatabase file:

"dataSources": [
  {
    "name": "sourceDB1",
    "connectionString": "Data Source=xxxx",
    ...
  },
  {
    "name": "sourceDB2",
    ...
  }
 ]

I use this powershell script to update connection strings :

if($args[0] -eq $null)
{
    Write-Host "Updates .asdatabase connection string. Parameters: %source name% %source connection string%"
}
else{

    $source=$args[0]
    $connectionstring=$args[1]

    write-host "updating "  $source  " connection string..." 

    $a = Get-Content 'Model.asdatabase' -raw | ConvertFrom-Json
    $a.model.datasources | % {if($_.name -eq $source){$_.connectionString=$connectionstring}}
    $a | ConvertTo-Json -depth 100| set-content 'Model2.asdatabase'

    If ($?)
    {
        write-host "updated successfully"
    }
}

Is there a more sane/sustainable approach?

Related Question: Continuous integration and Deploy SSAS tabular to Azure Analysis Services

1
Hi, friend, may I know how's the status of this? Free to share your comment or any of question below:-)Merlin Liang - MSFT
Hi Merlin, thanks for your "replace text" extension suggestion.For now I use the powershell script above, it's safer as it parses the json, as opposite to direct string replacement. I would still prefer a cleaner / more reliable approach, but haven't found one yet.user5226582

1 Answers

0
votes

What about consider to make use one extension which name is Replace Text in Source Files.

It contains 2 method, and the first one is replace by search pattern.

Search Start of Text

As the description says you're looking in each line of the source code for a text starting with what is entered here.

Sample Line -> [assembly: AssemblyInformationalVersion("1.1.1.1")]

So if you enter 'AssemblyInformationalVersion("' it will look for a line containing that text and stopping just at the end before the version 1.1.1.1.

Search End of Text

As the description says the task is looking for the 'End of Text' but only on the lines where the Start of Text already found a result.

Sample Line -> [assembly: AssemblyInformationalVersion("1.1.1.1")]

So if you enter '")]' it will look for the position just at the end of version 1.1.1.1.


Also, you can use the another task Replace In Files Text By Text. What its work logic is same with replace A with B directly, so it needs you input the original connection string value every times.

Just based on your scenario and your actual considering to choose one of them.