Advertisements

Archive

Posts Tagged ‘DevOps’

Azure DevOps – Getting started by committing a C# console project to Repo and set Policies

February 23, 2019 Leave a comment

Those who are hearing ‘Azure DevOps Services’ for the first time, its formerly known as ‘Visual Studio Team Services (VSTS)’.

And Team Foundation Server (TFS) is now called ‘Azure DevOps Server’.

Below table gives the glimpse of how VSTS features represents in Azure DevOps.

DevOps_14

To know more about Azure DevOps refer this link

In this article, I am going provide the steps to sign-up for ‘Azure DevOps’ and explain how to on board a C# console project.

Pre-Requisite:

  • Microsoft account.
    • You can also use your 30 days trail Dynamics Account to login.
    • If you’re a Visual Studio subscriber and you get Azure DevOps as a benefit, use the Microsoft account associated with your subscription

Sign up for Azure DevOps:

  • Navigate to the VS Portal and click on ‘Get started for free’ as highlighted below

DevOps_15

  • Log in with your ‘Microsoft Account’

DevOps_1

  • Once you complete the registration, you will be redirected to Azure DevOps portal.

DevOps_2

  • A new Organization would have got created by now and to sign in to your organization at any time, go to https://dev.azure.com/{yourorganization}.

Create a New Project:

Once you got your Organization ready, next you need to create a new ‘Project’.

  • On the ‘Create a Project to get started’ form, provide your project name and set the Visibility.
    • Set the Visibility to ‘Private’ if you are working on a customer project which you would not want to expose to Public.
    • ‘Public’ visibility is meant for Open Source projects.

DevOps_17

  • Under ‘Advanced’ tab, I am going with ‘Git’ as my Version Control and ‘Agile’ as Work item process.
  • Your ready with Project and we are close to on board our C# console project.

Repos:

After you create a new Organization and Project, you can begin coding with Git using Repos.

  • Click on ‘Repos’.
  • As a first step in Repos, add ‘README’ or ‘gitignore’, as shown in below.Note that this step is optional but very effective house keeping step.
    • README – You can provide description and objective of your project.
    • gitignore – Will ignore unwanted files to be added to repos.
      • As an example you don’t need components like (Actual nuGet packages, .suo files which comes with VS).
      • I’ve added ‘VisualStudio’ option to the ‘gitignore’ which ignores all unwanted VS files.

DevOps_3

  • Click ‘Initialize’
  • Now you would see 2 files added to your Repo.
  • As mentioned, ‘.gitignore’ contain unwanted file extensions, auto populated. You can add/remove if you want.

DevOps_4

  • ‘README.md’, is a Mark Down file which is a combination of Text and HTML tags. Add your project description.
    • Denotes <H1> tag; ## denotes <H2> tag.

DevOps_5

Clone the Repo to your computer:

To work with a Git repo, you clone it to your computer. Cloning a repo creates a complete local copy of the repo for you to work with.

In this article, I am going to use ‘Visual Studio’ to Clone the Repo. You can also use ‘Command line’ commands using ‘Command Prompt’

  • Click ‘Clone’ and select ‘Clone in Visual Studio’ option under ‘IDE’.

DevOps_6

  • Now Visual Studio opens up and you might need to provide your Microsoft Account credentials.
  • In case if you get ‘Unauthorization’ error, you can connect as below from your VS ‘Team Explorer’.

DevOps_16

  • Once you complete the clone, the 2 files (i.e., .gitignore, README.md) would synced to your computer folder.

Commit C# Console Project to Repo:

Once you Cloned of your DevOps ‘Project’ to your local computer folder, below are the steps to add a new C# console project to Repo.

  • Create a new C# console application project and save at the same folder location where you cloned your Azure Project.
  • Now you would see the Console project in your Visual Studio.
  • You would notice #5 in the Visual Studio footer, which denotes 5 new files are new and not synced to your Repo.

DevOps_7

  • You need to commit the files to sync with your Repo.
  • Click on #5 icon and provide mandatory ‘Commit comments’ and choose ‘Commit All and Push’ option to commit and upload the C# console project to Repo.

DevOps_8

  • Now, go to your Azure DevOps portal and you would see your C# console project.

DevOps_9

  • You can also Edit the class files directly from DevOps portal.

Branch Policies:

As you would have noticed, Visual Studio did not allow me to commit the files until I provide the ‘Comments’. Its a policy implied by default by DevOps.

Lets see how to configure the policies.

  • Once you create a new Project, DevOps will create a default ‘master’ branch.
    • Refer article for more details on ‘Branch’.
  • Under Repos->Branches, select ‘Branch Policies’ from the Branch menu.

DevOps_10

  • You can configure appropriate policies mainly to improve the code quality.
    • Refer link to know more details on Policies.

DevOps_11

Grant access on Project to Users:

For every new project you add to DevOps Organization, a new Team gets created with naming convention {Project Name} Team.

  • Click on ‘Teams’ tab as shown in screen below and pick your Project team.
  • ‘+Add’ to add users

DevOps_13.PNG

  • Refer this link to know more details on managing Teams.

Service Hooks:

  • Service hooks let you run tasks on other services when events happen in your Azure DevOps Services projects.
  • For example, you can create an entry in Azure Service Bus when there Code commit happens.

DevOps_12

  • Refer this article for more details on ‘Service Hooks’

In my next article I will share the details on how to implement Build activities using Pipelines

🙂

Advertisements