Friday, February 2, 2018

How to set up SSH keys in Azure Repos | Setup SSH keys and Java Web App in Repos in Azure DevOps

How to set up SSH keys in Azure Repos and Setup WebApp in Azure Repo


Go to your visual studio home page. You should be able to go by clicking on the below URL.
https://dev.azure.com/

Create a new project by clicking on New project and enter project details like below. This will create a project dashboard.


Once project is created, Click on Repos.


 Click on initialize link to add README.



Click on clone link on the top right hand side.
Click on SSH link
Click Manage SSH keys

Click Add

Go to any virtual machine you had setup that has both Java and Maven installed. If you would like to know how to create a Virtual Machine in Azure Cloud, click here to do so.

Create the SSH keys by executing the below command:
(If you already have keys generated, you can overwrite it or skip to next step to copy keys)
ssh-keygen

execute the below command to copy the keys:

cat ~/.ssh/id_rsa.pub

Add the public keys.
Once keys added into Azure DevOps, go to Repos, copy the SSH clone url

Go to your machine where you have installed Java, Maven, preferably your EC2. Execute this command:
git clone <ssh_url>

This should download the empty repo from Azure DevOps to local machine(or ec2).
now after cloning, it will create a folder with repo name..

type 

ls -al to see the folder name after you cloned.

go inside that folder by
cd reponame

Now create the maven project executing the below command:
mvn archetype:generate -DgroupId=com.cf -DartifactId=MyAwesomeApp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

type git status --> to see the newly created project
git add *
git status

git commit -m "my first project check-in to Azure Repos"
git push

Now go to Azure DevOps, Select the Repos —> Files —> you should see the project uploaded here.



1 comment:

  1. In case you are executing above mvn command on Windows platform it will fail. Use below updated command for the successful execution:
    mvn archetype:generate "-DgroupId=com.cf" "-DartifactId=MyAwesomeApp" "-DarchetypeArtifactId=maven-archetype-webapp" "-DinteractiveMode=false"

    ReplyDelete