question

TomGutzler-1570 avatar image
0 Votes"
TomGutzler-1570 asked DSPatrick commented

Starting a process from Azure deployment agent task

Hi,

I have configured my Azure release pipeline with a deployment group job that is targeting a pool of windows machines.
After successful deployment, that job is running a power shell script task which attempts to start a windows executable with GUI on the target machine. Then it waits for 1s and checks if the executable is running. I'm getting a valid process ID back in the log file of the deployment job.
But when I check on the PC after the release is complete I don't see the executable running and task manager shows no process with the logged process ID.
Is there something I need to do to make sure it keeps running when the agent has finished its work?

The agent is running as the same user which is logged on.

This is the power shell script

 $p = Get-Process -Name $(Process) -ErrorAction SilentlyContinue
 if ($p) {
   Write-Host "$(Process) is running with PID" $p.Id -Background Green
 } else {
   Write-Host "$(Process) is not running - starting $(PathToExecutable)"
   Start-Process -FilePath "$(PathToExecutable)"
   sleep 1
   $p = Get-Process -Name $(Process) -ErrorAction SilentlyContinue
   if ($p) {
     Write-Host "$(Process) is running with PID" $p.Id -Background Green
   } else {
     Write-Host "Could not start $(Process)" -Background Red
   }
 }

And an example log file

 2020-05-19T02:12:57.7435760Z ##[section]Starting: Start Process Unless Running
 2020-05-19T02:12:57.7619447Z ==============================================================================
 2020-05-19T02:12:57.7619818Z Task         : PowerShell
 2020-05-19T02:12:57.7620096Z Description  : Run a PowerShell script on Linux, macOS, or Windows
 2020-05-19T02:12:57.7620357Z Version      : 2.165.0
 2020-05-19T02:12:57.7620622Z Author       : Microsoft Corporation
 2020-05-19T02:12:57.7620951Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
 2020-05-19T02:12:57.7621328Z ==============================================================================
 2020-05-19T02:12:59.4240091Z Generating script.
 2020-05-19T02:12:59.4987674Z ========================== Starting Command Output ===========================
 2020-05-19T02:12:59.5297125Z ##[command]"C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\azagent\A1\_work\_temp\97741594-232f-4de0-adeb-df1929e6c245.ps1'"
 2020-05-19T02:12:59.8622987Z <Process> is not running - starting <App.exe>
 2020-05-19T02:13:01.0336371Z <Process> is running with PID 11232
 2020-05-19T02:13:01.1572479Z ##[section]Finishing: Start Process Unless Running

Also, sorry for tagging azure-virtual-machines when it's not about virtual machines but I just couldn't find a matching tag :(

not-supported
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DSPatrick avatar image
0 Votes"
DSPatrick answered

QnA currently supports the products listed here (more to be added) Better to reach out to subject matter experts in dedicated forums over here.


https://developercommunity.visualstudio.com/spaces/21/index.html


https://developercommunity.visualstudio.com/spaces/22/index.html


(please don't forget to mark helpful replies as answer)


Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management


Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TomGutzler-1570 avatar image
0 Votes"
TomGutzler-1570 answered DSPatrick commented

Thanks, will repost there

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You're welcome.


0 Votes 0 ·