How do I Automate the creation of Azure Repos?

So far ive figured out how to create an azure repo with python. My code is below. I am having trouble figuring out how to delete repos with python. Then I need to automate the entire process. Here is what i have so far.

import subprocess   def run_command(command):     process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)     output, error = process.communicate()     return output, error   output, error = run_command('az repos create --name="newnewchris" --organization="https://dev.azure.com/iDevOpsio/" --project="iDevOps.io"') print(output) print(error)  output, error = run_command('git clone https://[email protected]/iDevOpsio/iDevOps.io/_git/chrisnewnew') print(output) print(error)  output, error = run_command('git remote add origin https://[email protected]/iDevOpsio/iDevOps.io/_git/chrisnewnew') print(output) print(error)  output, error = run_command('git push -u origin --all') print(output) print(error) 
Add Comment
1 Answer(s)

I would check out https://pypi.org/project/azure-cli/ It looks to be a python wrapper for Azure CLI. Azure CLI has az repo. https://docs.microsoft.com/en-us/cli/azure/ext/azure-devops/repos?view=azure-cli-latest

So Then you can use that to create the repo, and use git to push updates. https://gitpython.readthedocs.io/en/stable/tutorial.html

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.