Copying Recordsdata from Git Repository to Azure Storage in Azure DevOps

Beneath are just a few situations the place you wish to add recordsdata from Git repos to Azure Storage Account

  1. Add the Linked ARM (Azure Useful resource Supervisor) Templates to Storage Accounts for execution.
  2. Importing any studies for future reference.
  3. Add any static assets (like photographs, CSS, and JS recordsdata)


Please guarantee, you create the under.

  • Create an Azure Storage Account
  • Create a Storage Container

Let’s now perceive how you can copy the recordsdata from the git repository to Azure Storage inside the Azure DevOps CI/CD pipelines.

Beneath are the steps to be carried out to be able to implement the copy performance.

  1. Obtain the code from Azure DevOps Git Repository to Azure Pipelines Agent
  2. Copy the Recordsdata from the Agent Listing to Azure Storage Container utilizing Azure CLI.

Step 1. Obtain the code

As a way to obtain the code from the Azure DevOps. Git repository, we have to add a (optionally available) step known as checkout utilizing the under code


Beneath is the output of the step as soon as it’s added to the YAML Pipeline.

Azure DevOps

As proven within the above display screen seize, the checkout step downloads the code from the git repo to a folder known as s (/house/vests/work/1/s). This folder will be referenced utilizing an Azure DevOps pre-defined variable known as System.DefaultWorkingDirectory

As soon as the code is obtainable, we have to add one other Azure DevOps activity which may add the code from the Agent’s native folders to Azure Storage Account. Let’s perceive how you can implement the identical.

Step 2. Copy recordsdata from folder s to the Storage Account container

Let’s now add a brand new Azure CLI step to execute the Azure CLI command which copies the recordsdata/folders from the native Agent listing to the Azure Storage Account as proven under.

Azure CLI

When you click on on the Add button within the earlier step, the under YAML code shall be added.

- activity: AzureCLI@2
  displayName: Copy Recordsdata
    azureSubscription: 'azure-dev-serviceconnection'
    scriptType: 'pscore'
    scriptLocation: 'inlineScript'
    inlineScript: 'az storage blob upload-batch --source $(System.DefaultWorkingDirectory) --destination $(ContainerName) --account-name $(StorageAccountName) --overwrite'

The above command is self-explanatory. Please be happy to put up your questions within the feedback field on the backside of this text.

When you run the pipeline, you’ll be able to see the logs which present the recordsdata are uploaded efficiently.


Let’s additionally confirm if the recordsdata have been uploaded to the Storage Container. Beneath is the display screen seize of the Container the place the recordsdata are uploaded.


Beneath is the whole YAML Code.

  - identify: StorageAccountName
    worth: azdevopsdeveusstrgacc1
  - identify: ContainerName
    worth: ado-tips

  - checkout: self
  - activity: AzureCLI@2
    displayName: Copy Recordsdata
      azureSubscription: 'azure-dev-serviceconnection'
      scriptType: 'pscore'
      scriptLocation: 'inlineScript'
      inlineScript: 'az storage blob upload-batch --source $(System.DefaultWorkingDirectory) --destination $(ContainerName) --account-name $(StorageAccountName) --overwrite'


On this article, we’ve got discovered how you can write the Azure DevOps – YAML-based pipeline for importing the recordsdata from Azure DevOps – Git repo to an Azure Storage Account.

Know extra about our firm at Skrots. Know extra about our companies at Skrots Providers, Additionally checkout all different blogs at Weblog at Skrots

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button