Azure DevOps For Web Devlopment - Part Two - Azure Repos

Scope

This article is part of a series of four articles on getting an ASP.NET web app live on Azure App Services using Azure Repos and Azure Pipelines.

Azure DevOps For Web Development - Part One

This is the second article of the series and I will walk you through creating your local Git repository and pushing it to Azure Repos.

Code Repository with Azure Repo

Git is the most widely used version control system, which can track file changes in repositories, coordinate code changes across your team, and allow you to roll back to any version of your code with ease. Git is a distributed version control system; your local copy of the code is a complete version control repository. This makes it easy to work offline or remotely. You commit your work locally and then sync your local repository with the repository on the server. Read about basic git commands to get you going here.

Code Repository

Azure DevOps includes free unlimited private Git repositories. Git in Azure Repos is your standard Git. You can use the clients and tools of your choice, such as Git for Windows, and Mac, third-party Git services, and tools such as Visual Studio Code.

Clicking on Repos in the navigation bar brings you to the code section, displaying an empty git repository with useful instructions on how to get started bringing your code to Azure Repos. Azure DevOps portal provides some handy keyboard shortcuts to move around, to Go the Code section, you can also press G C.

Press G C

Here are your options bring your code to Azure Repos,

  1. Clone the empty git repository to our computer using the git command line or clone directly into IDEs which have the Azure DevOps Plugin.
    VS code
  2. Push an existing git repository using the provided commands, given you have git installed on your machine.
  3. Import a git repository from the URL.
    Git repository
  4. Initialize the repository with README & .gitignore
    Actionscript

This article will use an ASP.NET project code straight out of Visual Studio and the code will be pushed from a local machine (Option 2) using Git for Windows. (Read how to create an ASP.NET project in Visual Studio here)

Step 1. In the solution folder, run the command git init to initialize a git repository.

Step 2. Add all the files using git add.

Step 3. Commit changes using git commit -m “<message>”.

Git commit

At this point, you have your local git repository ready. You now have to push the repository using the two commands provided on Azure DevOps.

HTTPS

The git remote add origin <link to remote server> command adds a remote repository named origin to the local repository.

The git push -u origin --all finally pushed the local code to the remote repository. The -u flag links local branches to remote ones, the origin specifies the remote server we added earlier, and --all instructs to push all branches.

On running the git push command, you will need to authenticate your account so Git can verify you have permission to make changes to the remote repository on Azure Repos.

Azure Repo

Once authenticated, your code will be pushed.

Code Repository

You should see all your files online as soon as you refresh your page.

Files

Conclusion

In this second part of the Azure DevOps for Web Development Series, we saw how to initialize a local git repository and push your code to Azure Repos to save work and manage code changes across your team. In the next article of this Azure DevOps series, we will have a look at how to automate your builds using Azure Pipelines.

See Also