E2E Python solution in DevOps – Part 3: Azure DevOps preparation

In this serie I show you how you can create a PyPi ready solution which is stored on GitHub and has fully automatized build-test-deploy CI/CD pipeline in Azure DevOps. Furthermore you will be able to use it from command line like azure-cli or aws-cli.

Table of content


Today we have a simple task: prepare our pipeline in Azure DevOps. For this we follow the well known steps: create account in Azure DevOps, create project, configure project, create credentials for git and PyPi. Let’s start. 🙂

Some words about Azure DevOps

Azure DevOps is the improvement of Visual Studio Team Services (VSTS) – this is the simplest definition. Obviously you can find a very good information collection and an introduction on official page of Microsoft.

Then you can start the deep diving here.

Create account in Azure DevOps

If you click on

here or on starting page of Azure DevOps you have chance to create a brand new account or sign-in to your existing account with your Microsoft related accounts.

Of course if you don’t have Microsoft related account you can create here.

First steps in Azure DevOps

When you have created your account successfully you can see the summary page of your first project inside your default organisation.

This seems quite cool and as you will observe this covers everything you need regarding a DevOps process such as repository (same as Git), dashboards for your agile or scrum process, pipelines, etc.

To be honest you don’t necessary to store your code on GitHub anymore. Nevertheless I would like to show you how you can make a working solution for your code which is on GitHub.

Of course this serie is also useful for you, if you decided you would store your code here (Azure DevOps – VSTS). In next part you can see it how. I mean the steps are same merely the source related configuration is a little bit different.

Create project in Azure DevOps

As you can see after you created your account you have already a project. However in the future you will create one or more projects for your other solutions.

  1. Click on Azure DevOps home icon on top left side of screen
  2. Click on Create Project on top right side of screen
  3. Add a project name like: pypi-project
  4. Text some description if you need
  5. Set the visibility according to your internal policy (public or private). I use public now.
  6. Under Advanced option you can configure the required version control (Git or Team Foundation) and project methodology (Agile, CMMI, Scrum). I use Git and Agile.
  7. Then click on Create button.
  8. After a minute you can see your newly created project

You can find it here: https://dev.azure.com/the1bit/pypi-project

Configure project

This topic is not so important for us, all the same you should know some thing for the future.

When you create a big DevOps project you need to manage users and other things.

To invite something to contribute your code (be member of your project), you should click on Invite button on top right side of screen.

then type his/her account or name of group to the required field then click on Add button on bottom right side of screen.

Other project related configuration options are available when you click on Project settings button on bottom left side of screen

Here you can configure several important things such as project visibility, security related things, notifications, service hooks, dashboards, pipeline settings and test related options.

Create credentials for git and PyPi

The external systems (GitHub and PyPi) credentials related configuration is available under Project settings > Pipelines > Service connections.

To add a new connection we have to do the followings.

(I assume you have registered accounts on GitHub, PyPi test and PyPi production site)

Register your GitHub credential

  1. You have to generate a Personal access token on GitHub. (Recommended scopes — repo, read:user, user:email, admin:repo_hook)
  2. Copy the newly generated access token to clipboard.
  3. Click on New service connection button inside Project settings >
    Pipelines in your Azure DevOps project.
  4. Choose GitHub
  5. In the new window you have to choose the Personal access token at Choose authentication option.
  6. Add a name for your connection like pypi-project on GitHub
  7. Paste the GitHub access token to Token field.
  8. Tick the Allow all pipelines to use this connection option.
  9. Then click on OK button.
  10. Some seconds later you have a working connection between GitHub and your Azure DevOps project.

Register your PyPi test credential

  1. Click on New service connection button inside Project settings >
    Pipelines in your Azure DevOps project.
  2. Choose Python package upload
  3. In the new window you have to choose Username and Password option.
  4. Add a name for your connection like pypi-project on PyPi test
  5. Python repository url for upload value: https://test.pypi.org/legacy/
  6. EndpointName value must be the name our package on PyPi. So it must be unique and mustn’t contain any space or special character. My example value is: the1bitdemo.
  7. Then type your test PyPi username to Username field and your password to Password field.
  8. Tick the Allow all pipelines to use this connection option.
  9. Then click on OK button.
  10. Some seconds later you have a working connection between test PyPi and your Azure DevOps project.

Register your PyPi prod credential

  1. Click on New service connection button inside Project settings >
    Pipelines in your Azure DevOps project.
  2. Choose Python package upload
  3. In the new window you have to choose Username and Password option.
  4. Add a name for your connection like pypi-project on PyPi prod
  5. Python repository url for upload value: https://upload.pypi.org/legacy/
  6. EndpointName value must be the name our package on PyPi. So it must be unique and mustn’t contain any space or special character. My example value is: the1bitdemo.
  7. Then type your prod PyPi username to Username field and your password to Password field.
  8. Tick the Allow all pipelines to use this connection option.
  9. Then click on OK button.
  10. Some seconds later you have a working connection between prod PyPi and your Azure DevOps project.

Great. We are done with the preparation of our Azure DevOps project.

I hope the steps are clear and you can configure them in your project.

Next time we are going to create the pipeline for test PyPi. 🙂

Leave a comment

Positive SSL