To add users users after a deployment to a Azure Analysis Services cube you can do this manually with the Management tools or with the Visual Studio. But with a Continiuos Deployment (CI/CD) and different stages, you need mostly add different users/groups to add to the roles. So, you need todo this dynamiccaly with some scipts. I found in the marketplace a addin to do this with DevOps by using a pipline. But, unfornatially this adding does not work and you can only onee user/group by using one step. So, I decided to do this with PowerShell to add more than one user in one step.
I added my deployment user as a SSAS admin with the portal (you can also do this with the Management Studio)
![](https://www.flip-design.de/wp-content/uploads/2021/09/image.png)
After that, I created this PowerShell script and added this to my Repo and published it to DevOps to use it inside a Pipeline: This script connects to my Analysis Service and adds a user to a role. use it inside a Pipeline: This script connects to my Analysis Service and adds a user to a role.
[CmdletBinding()]
param (
$ParamUser,
$ParamPassword
)
$myPassword = $ParamPassword
$myUsername = $ParamUser
$password = ConvertTo-SecureString $myPassword -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ($myUsername, $password)
Login-AzAccount -Credential $credential
Import-Module SqlServer -DisableNameChecking
Add-RoleMember `
-Server asazure://westus.asazure.windows.net/ssas001 `
-membername "asadmin@plenz.onmicrosoft.com" `
-database "adventureworks" `
-rolename "Internet Sales Manager" `
-Credential $credential
Here you see the script inside my Repo at DevOps
![](https://www.flip-design.de/wp-content/uploads/2021/09/image-1.png)
Next, I created a pipeline, and I added the needed credentials to connect to the SSAS server as variables.
![](https://www.flip-design.de/wp-content/uploads/2021/09/image-2.png)
After doing this, I created an Azure PowerShell task inside my pipeline this one uses the PowerShell script from the repo and pushes the variables as parameters to the script.
![](https://www.flip-design.de/wp-content/uploads/2021/09/image-3.png)
After tunning the pipeline, the user from the script is added to the role.
![](https://www.flip-design.de/wp-content/uploads/2021/09/image-4.png)