In this article, we are going to learn how to copy the files from the git repository to an Azure Storage Account.
- A valid Azure Subscription
- A valid Azure DevOps Account
- Create a Storage account and create a Container named “sourcefiles”. As shown below the container is 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.
- Build Pipeline – The build pipeline copies the files from Azure DevOps repository to the Azure DevOps artifacts
- 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.
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.
|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.
Step1: Copy files Task
Step1: 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.
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.
Step1: 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.
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.
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.
Let’s run the Pipeline again and it worked well as shown below.
And, I can see both the files copied into Storage Account as well which is shown below.
That’s it. We have learnt how to copy the files from Azure DevOps git to Storage Account.
For getting more updates on Azure DevOps, you can join my WhatsApp group at Azure DevOps World
Do you like this article? If you want to get more updates about these kind of articles, you can join my Learning Groups
Thanks Praveen for putting this on your website. I did it using your instructions and it works.
Thanks. I had the same problem with the Azure File Copy task’s version 4. Reading your post helped.