遗憾的是,部署模型时,不会保留结构化(也称为Power Query)数据源凭据。我前段时间报告过这是产品团队的一个错误,但还没有得到回复。如果可以,请考虑使用遗留(也称为提供者)数据源,因为这些数据源可在部署之间保留凭据。
或者,您可以使用a以编程方式应用密码 TMSL“createOrReplace”脚本 。创建脚本的最简单方法是连接到SSMS中的Analysis Services,右键单击连接(也称为数据源),然后选择“脚本连接为”> “创建或替换”> “新查询编辑器窗口”。在生成的脚本中,确保正确设置了密码:
{ "createOrReplace": { "object": { "database": [...] , "dataSource": "File/\\\\Share\\AcaiDataTempShare\\Data\\LumenEventPropertiesExport tsv" }, "dataSource": { [...] "credential": { "AuthenticationKind": "Windows", "kind": "File", "path": "\\\\Share\\acaidatatempshare\\data\\lumeneventpropertiesexport.tsv", "Username": "domain\\username", "Password": "<<< YOUR PASSWORD HERE >>>" }, [...] }
然后,您可以将此脚本作为部署管道的一部分调用 - 例如,使用PowerShell 调用-ASCMD 小命令。
这是我最终创建的最终脚本。
# Get tools path $msBuildPath = Get-MSBuildToPath $Microsoft_AnalysisServices_Deployment_Exe_Path = Get-Microsoft_AnalysisServices_Deployment_Exe_Path # BUild smproj & $msBuildPath $projPath "/p:Configuration=validation" /t:Build Get-ChildItem $binPath | Copy -Destination $workingFolder -Recurse $secureStringRecreated = ConvertTo-SecureString -String $AnalysisServerPassword -AsPlainText -Force $cred = New-Object System.Management.Automation.PSCredential($AnalysisServerUserName, $secureStringRecreated) #$plainText = $cred.GetNetworkCredential().Password #region begin Update Model.deploymenttargets # Read Model.deploymenttargets [xml]$deploymenttargets = Get-Content -Path $deploymenttargetsFilePath $deploymenttargets.DeploymentTarget.Database = $AnalysisDatabase $deploymenttargets.DeploymentTarget.Server = $AnalysisServer $deploymenttargets.DeploymentTarget.ConnectionString = "DataSource=$AnalysisServer;Timeout=0;UID=$AnalysisServerUserName;Password=$AnalysisServerPassword;" $deploymenttargets.Save($deploymenttargetsFilePath); #endregion #region begin Update Model.deploymentoptions # Read Model.deploymentoptions [xml]$deploymentoptions = Get-Content -Path $deploymentoptionsFilePath # Update ProcessingOption to DoNotProcess otherwise correct xmla file wont be generated. $deploymentoptions.Deploymentoptions.ProcessingOption = 'DoNotProcess' $deploymentoptions.Deploymentoptions.TransactionalDeployment = 'false' $deploymentoptions.Save($deploymentoptionsFilePath); #endregion # Create xmla deployment file. & $Microsoft_AnalysisServices_Deployment_Exe_Path $asdatabaseFilePath /s:$logFilePath /o:$xmlaFilePath #region begin Update .xmla #Add passowrd in .xmla file. $xmladata = Get-Content -Path $xmlaFilePath | ConvertFrom-Json foreach ($ds in $xmladata.createOrReplace.database.model.dataSources){ $ds.Credential.AuthenticationKind = 'Windows' $ds.Credential.Username = $AnalysisServerUserName #Add password property to the object. $ds.credential | Add-Member -NotePropertyName Password -NotePropertyValue $AnalysisServerPassword } $xmladata | ConvertTo-Json -depth 100 | Out-File $xmlaFilePath #endregion #Deploy model xmla. Invoke-ASCmd -InputFile $xmlaFilePath -Server $AnalysisServer -Credential $cred`enter code here`