Azure Devops - Copy Files From Git Repository To Azure Storage Account

In this article, we are going to learn how to copy the files from the git repository to an Azure Storage Account.
 
Prerequisites
  1. A valid Azure Subscription
  2. A valid Azure DevOps Account
  3. Create a Storage account and create a Container named “sourcefiles”. As shown below the container is empty.
Azure Devops - Copy Files From Git Repository To Azure Storage Account
Azure DevOps – Storage Account – Empty
 
In this article, we are going to build the following two pipelines using Classic editor. You can follow the same approach even if you would like to create YAML base pipelines.
  1. Build Pipeline – The build pipeline copies the files from Azure DevOps repository to the Azure DevOps artifacts
  2. Release Pipeline – The release pipeline picks the files from the Azure DevOps artifacts to Storage Account.
Let’s start authoring the pipelines
 

Create an Artifactory

 
As shown below, create a set of files in the repository that you would like to copy to Azure Storage account. For the sake of this article, I have created a folder and two files.
 
Azure Devops - Copy Files From Git Repository To Azure Storage Account
Azure DevOps – Git Repository – Static Files
 

Create Build Pipeline

 
In this section, we will work on creating a Build pipeline for copying the files from the Azure DevOps – Git repository to Azure DevOps antifactory. It’s a two-step process.
 
Step Task Comments
Step1 Copy Files In this step, the Copy Files task copies the files from the Azure DevOps repository to a Staging directory $(Build.ArtifactStagingDirectory) of the Agent
Step2 Publish Build Artifacts In this step, the Publish Build Artifacts task, copies the files from the Staging Directory $(Build.ArtifactStagingDirectory) to the Azure DevOps artifacts from where the Release pipeline could pick.
 
Below is how it looks once the above two tasks are created.
 
Step 1 - Copy files Task
 
Azure Devops - Copy Files From Git Repository To Azure Storage Account
Azure DevOps – Build Pipelines – Copy Files Task
 
Step 1 - Publish Build Artifacts Task
 
Azure Devops - Copy Files From Git Repository To Azure Storage Account
Azure DevOps – Build Pipelines – Publish Build Artifacts Task
 
Run the Build Pipeline to quickly validate if everything is working fine. If you see the text 1 published then the Build pipeline is working well. You can also click on 1 Published artifact and see the contents to ensure that the required files are packages as artifact.
 
Azure Devops - Copy Files From Git Repository To Azure Storage Account
Azure DevOps – Build Pipelines – Published Artifact
 

Create Release Pipeline

 
Let’s now work on authoring the Release pipeline with an Empty Job and configure the below steps.
 
Add an Artifact by choosing the Build Pipeline as shown in the below screenshot.
Azure Devops - Copy Files From Git Repository To Azure Storage Account
Azure DevOps – Build Pipelines – Add Artifact
 
Step 1 - Azure File Copy task
 
In this section, let’s use the Azure File Copy task to copy the files from the Azure DevOps artifacts to Azure Storage Account.
 
Azure Devops - Copy Files From Git Repository To Azure Storage Account
Azure DevOps – Release Pipelines – Azure File Copy
 
That’s it. We have configured both the Build Pipeline and the Release pipeline. Let’s run the Release pipeline by clicking on Create Release button
 
In my case, I have faced an error with the message Status: 403 This request is not authorized to perform this operation using this permission as shown below.
 
Azure Devops - Copy Files From Git Repository To Azure Storage Account
Azure DevOps – Release Pipelines – Azure File Copy – Version 4 error
 
It looks like there is an error in the Azure File Copy task’s version 4. So, I have changed the version back to 3 as shown below.
 
Azure Devops - Copy Files From Git Repository To Azure Storage Account
Azure DevOps – Release Pipelines – Azure File Copy – Version 3
 
Let’s run the Pipeline again and it worked well as shown below.
 
Azure Devops - Copy Files From Git Repository To Azure Storage Account
Azure DevOps – Release Pipelines – Successful Release
 
And, I can see both the files copied into Storage Account as well which is shown below.
 
Azure Devops - Copy Files From Git Repository To Azure Storage Account
Azure DevOps – Storage Account
 
That’s it. We have learnt how to copy the files from Azure DevOps git to Storage Account.