3

I have a pipeline with the steps below:

  • Create a Resource Group
  • Create a Virtual Machine from an image
  • Copy a Python project to VM created in the previous step

This Python project is an RPA (Robotic Process Automation). Now, I need to execute this Python project inside the VM and get the outputs from it to know what is going on, what the robot is doing. This robot read some sites and internal software.

Is there a way to execute a script inside a Virtual Machine from a Pipeline and get its console outputs? Any clue?

I saw this running on Jenkins.

fds13
  • 65
  • 8

1 Answers1

2

If you are having Microsoft host the VM for you, there may be a way to "talk" to said VM as it is hosted on Microsoft's platform. However, the only way that I know of is to deploy an agent to the VM and select it as a resource target to run tasks on, such as copying your Python project and even running it.

Have you attempted this yet?

Mike0684
  • 76
  • 6
  • When do you say about the agent would be from the Environment menu? And instead of copying the project into the VM, have it running directly from the pipeline pointing to this environment with the VM? I'll try it that way. – fds13 Oct 13 '21 at 12:39
  • I'm trying, but get stuck in the "Use Python Version" step. Getting error: ##[error]Version spec 2.7 for architecture x64 did not match any version in Agent.ToolsDirectory doesn't matter what version I try. Any clue? – fds13 Oct 14 '21 at 13:04
  • 1
    I'm not exactly sure about setting up to work as an environment, but when doing so in an Agent, you need to "tell" the Agent what its capabilities are. If the Agent was created in the C:\Agent folder, then in the C:\Agent\_work\_tool folder, add the following, replacing 3.8.0 with whatever version you are using, and x64 with x86 if it is a 32bit system: Python\3.8.0\x64.complete Python\3.8.0\x64\<> Inside the x64 folder is where the agent will run Python, so you will need all the traditional files like python.exe, python3.dll, python38.dll, etc. Hope that helps! – Mike0684 Oct 15 '21 at 15:16
  • I think I understand what you are saying now. I need to use a self-hosted agent. sorry for my silliness. I will try it right now! – fds13 Oct 15 '21 at 21:10
  • Not a problem! How did this end up working out for you? – Mike0684 Oct 18 '21 at 19:39
  • Yeah! Worked like a charm. I created a pipeline with build and execution. As the project is running on VM, I can see the progress and consequently the outputs of the execution. It's exactly what I need. Now my pipeline runs the setup.py and after the main.py. Many thanks! – fds13 Oct 19 '21 at 23:01
  • 1
    Not a problem! Don't forget also about the Logging Commands in Pipelines YAML, either, they're INCREDIBLY powerful! https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash Syntax in python to accomplish: import logging; logging.basicConfig(format='%(message)s', level=logging.INFO); logging.info("##vso[task.setprogress value={};]Upload Log".format(int(state/maxStates*100))); logging.warning('##[debug]This is a debug message"); logging.info("##vso[task.setvariable variable=pipelinesVar;]{}".format(pythonVar)) – Mike0684 Oct 20 '21 at 17:18