Sync work items between Azure devops server to Azure devops Cloud - azure-devops

We have a use case where epics and features are maintained in Azure DevOps cloud and user stories in Azure DevOps Server.
Now we are looking for some kind of connectors to sync the data to get complete traceability in Azure DevOps Cloud?
Do you have any suggestions?

You can export work items from server and then import them to service using CSV. Here are the detailed steps:
In Azure DevOps Server, go to "Boards/Queries". Create a query to include all work itmes you want to export. Click "Column options" to include all fields you want. Then click "Export to CSV" to download a CSV file.
Open the CSV file. Delete the ID column and save the change.
In Azure DevOps Service, go to "Boards/Work items". Click "Import Work Items". Choose the CSV file in step 2. Finally, save the work items.
Some other advices:
REST APIs: You can get work items by Work Items - List. Then use them as request bodies to create work items by Work Items - Create.
Use Azure DevOps Server migration tool. However, this tool is more complex to use and requires specific server versions. Click the previous link to download the guide.

Related

Is it possible to update a file in azure devops repository using power automate?

I can't find any connector in power automate to update a file in azure devops repository.
I am trying to automate the process of checkin our deployment sheet in azure devops repository. My flow is triggered when the custom work item type is closed. An adaptive card is sent to teams where the user can update the logs. Then I want to automatically update the log sheet present in azure devops. Prior to this we used to update the sheet in excel and again commit it from visual studio.
For operations which are not supported by the default connector you could always look into using the Azure DevOps REST API service in combination with an Send an HTTP request to Azure DevOps action.
I would look into using for example the Pushes - Create method:
https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pushes/create?view=azure-devops-rest-6.0&tabs=HTTP
Have a look at this StackOverflow thread, that might be useful as well:
How to use Azure DevOps REST API to Update File?

How to backup the data on Azure Devops?

I would like to schedule (for my company) a backup of our most important data in Azure DevOps, and that, for different reasons : security, urgent recovery required, virus, migration, etc...
I can execute a backup of the repositories and the Wikis (because it's under GIT, so easy to download), but how can do a backup of the "Board" section (Backlogs, Work items, etc...), and the build pipelines definitions?
How to backup the data on Azure Devops?
In current Azure DevOps, there is no out of the box solution to this. You could manually save the project data through below ways:
Source code and custom build templates: You can download your files
as a zip file. Open ... Repository actions actions for the
repository, file, or folder and choose Download as Zip. You can
also Download from the right side of the screen to download
either all of the files in the currently selected folder, or the
currently selected file.
This process doesn't save any change history or links to other
artifacts.
If you use Git, clone your repositories to retain the full project
history and all the branches.
Build data: To save logs and data in your drop build folders, see
View build results.
Work item tracking data: Create a work item query and open it using
Excel. Save the Excel spreadsheet.
This process doesn't save any attachments, change history, or links
to other artifacts.
build/release defintions: you could export the json file for them and then import them when restoring them.
There has been a related user voice, you could monitor and vote up it: https://developercommunity.visualstudio.com/content/idea/365441/provide-a-backup-service-for-visual-studio-team-se.html.
Here are some tickets(ticket1 ,ticket2) with the same issue you can refer to.
If you want to create scheduled tasks, you can write a script by using the Azure CLI with the Azure Devops Extension
As you said, for the repositories, it's quiet easy as they are Git repositories.
I wrote such a script that we could improve to also backup the Workitems, Backlog, etc...
It's open source, let me know what you would like to backup first and I'll improve it.
Github : azure-devops-repository-backup

Azure CLI Commands to add templates to workitems

I have Product backlog item, I am able to see templates from Azure Board UI. I want to use Azure CLI commands to add templates to the product backlog item. I have query to create Backlog which is working fine but I am not getting how to add templates available to the backlog.
I'm afraid there is no such Azure CLI command to add templates to workitems. If you would like that feature, please create a request for this feature here.

Azure devops pipeline get work items between builds

I'm looking for a pre-made option to take 2 builds, and compare the work items or PRs completed between them. i know there are REST API options in order to find out this information ( https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/get%20work%20items%20between%20builds?view=azure-devops-rest-5.0 ) , but i would rather not build my own app for this if one already exists. Is there something built into azure devops that shows this information, preferably in an exportable format? Is there possibly an existing devops extension in the store? Any searching i do just brings up the REST API call and nothing else unfortunately.
They seem to have changed it in Azure DevOps. We are using Azure DevOps Server (on-prem). In it, the old TFS-like work items comparison between the builds is possible when you actually deploy (execute a release) in a stage:
(in the screenshot below the right popup pane is showing the work item "diff" between the build currently deployed in TEST and the one which is about to be deployed now)
If you are open to it being generated at build time, you could look at using the Generate Release Notes Build Task from the marketplace.

How do I move an Azure DevOps project to a different organization?

I have got a project in an old org (from VSTS), that I want to move to my new one.
I can't see any options in Azure DevOps on migrating projects, or any information on the interwebs.
Anyone know how to do it?
If you just need to move repos, you can use the built in clone functions:
Go to the Azure Devops source repo -> Files
Click "Clone"
Choose "Generate Git Credentials"
Create the target repo in the target Azure DevOps
Choose "Import a repository"
Use the URL and credentials from Step 3
Done
This is not supported today. But this feature was planned to develop: make it possible to move a Team Project between Team Project Collections
If your Azure Devops project only tracks code versions using a single Git repo, hence no boards, user stories, tasks, pipelines, etc. then you can do the following:
Clone your project repo.
For example with Visual Studio.
You don't need to clone if you already have a local repo.
Destroy the association with the remote.
For this typically, you need to open a command line prompt in the folder that contains the .git database folder, most likely the solution folder of Visual Studio and type git remote rm origin.
Here is an example using git bash showing the content of the solution folder, including the .git database and the *.sln Visual Studio solution file:
Open the solution with Visual Studio if not already done.
It should now show that you have many commits waiting to be pushed to a remote. For illustration purpose, my toy project only have 8 commits in total.
Click the up arrow and choose your new remote, say a brand new Azure DevOps project, in the organization of your choice, then push.
You are now done cloning the project in another organization. If needed, then destroy the project in the old organization to complete the "move" operation.
There are 3 projects that I know of to achieve this.
A paid for option by Ops Hub -
OpsHub Visual Studio Migration Utility
An open source tool that requires making changes to the work item process template - Azure DevOps Migration tools
An lastly an Unofficial but still written by Microsoft tool to create Azure DevOps project templates - Azure DevOps Demo Generator & extractor tool
With the last one (the Demo Generator) you extract the project as a template, then apply it to the new organisation. As it is a tool for demo's there is no support provided and in my experience it works for simple projects but falls over on anything complex.
Expanding on others' answers, this post regards Pipelines.
Azure DevOps API
Migrating nearly all aspects of a project across organizations is doable, but it is a lot of manual work using the Azure DevOps API. The link below shows you all the end points, variables, etc. From there you'll probably want to write a Power Shell script and do a couple test runs to a dummy Organization.
https://learn.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-6.1&viewFallbackFrom=azure-devops-rest-6.0
In App options
If you avoid the API, there is no way to migrate pipelines that preserve build or release history, but you can preserve your configurations and processes by going into your Pipelines and selecting View YAML. From here you can either take this away as notes to recreate the GUI steps in your new org/project location, or actually adopt the YAML standard in your git repository.
I do not believe there is a way to migrate pipeline variables outside of the API. However, you can move the variables to Azure Key Vault and change your pipeline settings (YAML) to reference values from key vault. This is not a large amount of effort and is a nice process improvement.
Lastly, if you have any locally installed pipeline agents for releases, you will need to run the Power Shell script for your new organization on the boxes. Very simple 5m step, but right now the Agent Pools are not sharable across organization.
As #Frederic mentioned in his answer, we can actually easily do it with Visual Studio. I have done this without Visual Studio. The steps involved are below.
Add a User to Both Organization
Configure SSH Key
Update the SSH Key in Source DevOps and Clone the Repository
Check out all the Branches and Tags
Update the SSH Key in the Destination DevOps
Remove Old and Add New Origin
Push all the branches
The commands and detailed explanations can be found here.
BTW, if you need to change the entire Devops Organization tied to your personal Tenant (E.g. VS Enterprise Subscription) and move it to new Tenant, you can change the AAD and point it to the new one e.g. your EA Tenant on Azure commercial cloud.
Before you switch your organization directory, make sure the following statements are true:
You're in the Project Collection Administrator group for the
organization.
You're a member or a guest in the source Azure AD and a
member in the destination Azure AD
You have 100 or fewer users in
your source organization. Otherwise you will have to open a support ticket.
You may have to add the users back in destination org if they do not exist becuase they will loose access the moment you switch the AAD.
you could just download as a zip file and then download it to the destination repo