How can I run a custom artifact with different user

Category: azure devtest labs

Question

JazzStefan on Tue, 09 May 2017 13:36:31


In my DEVTestLab I'm trying to add a custom artifact, running a powershell script to restore a previously downloaded sqlserver backup into SqlServer Express 2014.

When running the restore command, it fails with message 'CREATE DATABASE permission denied in database 'master'.'

Can I run the script as admin? Or is there a different solution?

Replies

Leo Vildosola on Tue, 09 May 2017 17:19:03


Hi,

You cannot run the artifact as another user. However, you can update your artifact to run certain parts of your logic as another user. You can see a sample of how this is done by looking at any artifact that is based on chocolatey. The file of interest is startChocolatey.ps1.

I would also suggest you review the structure of the file and how it is configured in the artifactfile.json. Specifically, look at the format of the commandToExecute. That format, in combination to the structure of the PS1 file, will ensure your errors bubble up to the UI. I mention this because troubleshooting security issues will be a challenge in itself.