How to build Java project on existing virtual machine in Azure? In my project we are using Azure DevOps in which we have a pipeline which


pulls code from code repository
downloads Ubuntu container
installs Maven
downloads all the dependencies
then tries to build code


With this approach, every time we commit code in the repository, new container gets downloaded and Maven dependencies are downloaded as well.

Downloading dependencies itself is taking 10+ minutes which is kind of frustrating.

Is there any way in which we can cut down this build time? We have couple of virtual machines in Azure, is it possible to tell Azure DevOps pipeline to use these virtual machines to build the code instead of using containers?

I am sorry if this question is too broad/generic but I am new to DevOps and Azure in general so I don't know specific terms from DevOps world.

Thanks,
Chandra
You can use a custom build container image for your pipeline with Maven and all of your other dependencies. You will need to: 


Create a Dockerfile that installs Maven and all other dependencies that you have
Build the image and upload it to a custom Azure Container Registry
Modify your YAML pipeline file to reference the new build image


Sample:

resources:
   containers:
     - container: build_container
       image: demoxyz.azurecr.io/pipeline-build-image:latest
       endpoint: AzureCR
       options: '-v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock'


Here is an article that discusses the topic.