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