azureazure-devopsazcopy

azure command to copy blob from one directory to another directory


I am having below structure in my azure.

Container
   |-> Application (directory)
           |-> Build (sub directory)
                  |-> Release (Sub directory)
                           |-> build.tar.gz 

I am planning to change it in below structure so that the build will pick as per the environment.

Container
   |-> Application (directory)
           |-> Build (sub directory)
                |-> dev / pre prod / prod (sub directories)
                     |-> Release (Sub directory)
                           |-> build.tar.gz 

To do the same, I am trying to create a job will copy these builds from dev to pre prod and Pre-prod to prod directory.

Can you suggest the better approach to copy the build from one directory to another in same container.

I have tried with azcopy command to copy file from existing structure to new structure, but it is getting failed as sub directory dev / pre-prod / prod are not available.

Failed to create one or more destination container(s). Your transfers may still succeed if the container already exists.


Solution

  • I tried in my environment and got the below results:

    Initially, I have the same structure as yours in my environment.

    Portal:

    enter image description here

    You can use the below commands to copy the files from structure 1 to structure 2.

    Command:

    azcopy copy "https://venkat123.blob.core.windows.net/test/Application/build/release/sample1.tar.gz?<SAS-token>" "https://venkat123.blob.core.windows.net/test/Application/build/dev/pre-prod/prod/release/sample1.tar.gz<SAS-token>"  --recursive=true
    

    You can get the SAS token from the portal:

    enter image description here Output:

    enter image description here

    Portal: The above command executed successfully and copied files from structure 1 to structure 2.

    enter image description here

    Reference:

    azcopy copy | Microsoft Learn