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
- Part 1: Basic Python Code
- Part 2: Basic Release diagram
- Part 3: Azure DevOps preparation (current)
- Part 4: Create Azure DevOps pipeline – staging
- Part 5: Create Azure DevOps pipeline – master
- Part 6: Add test cases to project
- Part 7: Expand Python project functionality
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.
- Click on Azure DevOps home icon on top left side of screen
- Click on Create Project on top right side of screen
- Add a project name like: pypi-project
- Text some description if you need
- Set the visibility according to your internal policy (public or private). I use public now.
- 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.
- Then click on Create button.
- 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
- You have to generate a Personal access token on GitHub. (Recommended scopes — repo, read:user, user:email, admin:repo_hook)
- Copy the newly generated access token to clipboard.
- Click on New service connection button inside Project settings >
Pipelines in your Azure DevOps project. - Choose GitHub
- In the new window you have to choose the Personal access token at Choose authentication option.
- Add a name for your connection like pypi-project on GitHub
- Paste the GitHub access token to Token field.
- Tick the Allow all pipelines to use this connection option.
- Then click on OK button.
- Some seconds later you have a working connection between GitHub and your Azure DevOps project.
Register your PyPi test credential
- Click on New service connection button inside Project settings >
Pipelines in your Azure DevOps project. - Choose Python package upload
- In the new window you have to choose Username and Password option.
- Add a name for your connection like pypi-project on PyPi test
- Python repository url for upload value: https://test.pypi.org/legacy/
- 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.
- Then type your test PyPi username to Username field and your password to Password field.
- Tick the Allow all pipelines to use this connection option.
- Then click on OK button.
- Some seconds later you have a working connection between test PyPi and your Azure DevOps project.
Register your PyPi prod credential
- Click on New service connection button inside Project settings >
Pipelines in your Azure DevOps project. - Choose Python package upload
- In the new window you have to choose Username and Password option.
- Add a name for your connection like pypi-project on PyPi prod
- Python repository url for upload value: https://upload.pypi.org/legacy/
- 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.
- Then type your prod PyPi username to Username field and your password to Password field.
- Tick the Allow all pipelines to use this connection option.
- Then click on OK button.
- 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. 🙂
E2E Python solution in DevOps – Part 1: Basic Python Code – IT Blog for sharing
2019-01-20 @ 14:08
[…] Part 3: Azure DevOps preparation […]
E2E Python solution in DevOps – Part 2: Release diagram – IT Blog for sharing
2019-01-20 @ 14:03
[…] Part 3: Azure DevOps preparation […]