Integrating with Azure DevOps

In this guide, we’ll link a private Azure Devops repository to a Valohai project using a deploy key.

Requirements

Generate an SSH key pair

Use ssh-keygen to create a new SSH key pair.

You’ll need to generate a key without a passphrase, so just hit enter when prompted for a passphrase.

ssh-keygen -t rsa -b 4096 -f my-project-deploy-key

This will generate two files:

  • my-project-deploy-key.pub is the public key you add to Azure DevOps.

  • my-project-deploy-key is the private key you add to Valohai.

Don’t include the keys in your version control

You should not include these keys in the version control. Anybody that gains access to the my-project-deploy-key file contents will have read access to your repository, so use appropriate caution.

Add the public key to Azure DevOps

Find the my-project-deploy-key.pub file we generated in the last section, and it should contain one line that starts with ssh-rsa AAAA.... This line is the public key that we’ll be adding to Azure DevOps.

Now go to your Azure DevOps repository and navigate to the add deploy key page by clicking on User settings > SSH Public Keys

Azure DevOps - route to the deploy key creation page

Add the private key to Valohai

Go to app.valohai.com and navigate to the repository settings in your Valohai Project through Settings > Repository.

Valohai - route to repository settings

To make sure you get the correct repository URL, open Azure DevOps in another tab. On Azure DevOps, navigate to your project > Repos page and under Clone to your computer

Make sure you Clone with SSH. By default the HTTPS is selected so make sure you click the SSH button to get the right URL.

Then copy the text field with git@ssh.dev.azure.com:v3/<owner>/<project>/<repository>

Azure DevOps - where to find repository SSH URL

Next paste the SSH URL (git@ssh.dev.azure.com:v3/<owner>/<project>/<repository>) into the URL field.

On your local machine, find the my-project-deploy-key file (without the .pub extension) we generated before. It should contain multiple lines starting with -----BEGIN RSA PRIVATE KEY----- or something similar. The contents of this file are the private key we’ll be adding to Valohai. Copy and paste the contents of my-project-deploy-key into the SSH private key field.

Valohai - repository configuration example

After you click Save, Valohai links the Azure DevOps repository to the project and automatically fetches your code.

After you add new commits to your Azure Devops repository, remember to press the Fetch repository to update the code in Valohai.

Valohai - highlighted Fetch repository button