Skip to main content

Utilizing AzCopy to Copy Files From On-Premises to Azure Storage Accounts

Hands-On Lab

 

Photo of Gary McLeary

Gary McLeary

Azure Training Architect I in Content

Length

01:15:00

Difficulty

Intermediate

In this Hands-On Lab, we are going to utilize AzCopy to migrate data from one storage account to another. This is an important task because there will be a lot of scenarios within your day to day duties as an Azure Administrator in which you will have to migrate data from your on-premises environment to the Azure cloud, migrate data from one Azure Storage account to another Azure Storage account, and migrate data from your Azure storage account to your on-premises environment. We are going to complete this task by utilizing AzCopy and also Azure Storage Explorer. After completing this lab, you will be familiar with AzCopy and the different switches associated with it, learn how to copy files from on-premises to the Azure Cloud using AzCopy, copy files between different storage accounts, and also view storage content with Storage Explorer.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Utilizing AzCopy to Copy Files from On-Premises to Azure Storage Accounts

Introduction

In this Hands-On Lab, we are going to utilize AzCopy to migrate data from one storage account to another. We are going to complete this task by utilizing AzCopy and also Azure Storage Explorer.

Solution

Install AzCopy on a VM

  1. If you are not viewing the dashboard, click Dashboard on the left-hand menu.

  2. Click the lab-VM virtual machine.

  3. Copy the Public IP address.

  4. Use RDP to connect to the virtual machine using the IP address from the previous step.

  5. Log in using the credentials provided on the lab page.

  6. Type Server Manager in the search box and open the Server Manager

  7. Click Local Server on the left-hand menu.

  8. Click On link next to IE Enhanced Security Configuration.

  9. Select Off under Administrators.

  10. Click Ok.

  11. Open up a browser on the virtual machine and navigate to https://aka.ms/downloadazcopy.

  12. Run the downloaded file.

  13. Use the install wizard to install AzCopy with default settings.

  14. Click Finish.

Create a Storage Account and a Container Called datafiles.

Note: names are case sensitive

  1. In the AWS Management Console, click Storage accounts from the left-hand menu.

  2. Click Add.

  3. Under Storage account name enter a unique storage name account such as "azurestorageDATE".

  4. Click Review + create.

  5. Click Create.

  6. Click Go to resource.

  7. Under Blob servce, Click Blobs.

  8. Click + Container.

  9. Under Name enter "datafiles".

  10. Click OK.

Add a Second Storage Account

  1. Click Storage accounts from the left-hand menu.

  2. Click + Add.

  3. Under Storage account name, enter a unique storage name acocunt such as "azurestorage2DATE.

  4. Click Review + create.

  5. Click Create.

  6. Click Go to resource.

  7. Under Blob servce, Click Blobs.

  8. Click + Container.

  9. Under Name enter "datafiles".

  10. Click OK.

Use AzCopy to Copy Files From the Local System to the First Storage Account

  1. In the virtual machine, enter "cmd" in the Start Menu.

  2. Navigate to the AzCopy directory.

    cd "C:Program Files (x86)Microsoft SDKsAzureAzCopy"
  3. Start entering the AzCopy command.

    azcopy /Source:C:WindowsSystem32drivers
  4. Navigate back to the Azure portal.

  5. On the Storage accounts dashboard, select the first storage account: azurestorageDATE.

  6. Under Blob service click Blobs.

  7. Click the ellipsis (...) at the end of the datafiles row.

  8. Click Container properties.

  9. Copy the URL.

  10. Return to the virtual machine and paste the destination to the end of the command.

    azcopy /Source:C:WindowsSystem32drivers /Dest:CONTAINER_1_URL
  11. Return to the Azure portal.

  12. Under Settings click Access keys.

  13. Copy the key under key1.

  14. Return to the virtual machine and paste the public key to the end of the command.

    azcopy /Source:C:WindowsSystem32drivers /Dest:CONTAINER_1_URL /Destkey:ACCESS_KEY_1
  15. Run the command.

  16. Return to the Azure portal.

  17. Click Blobs under Blob service.

  18. Click Storage Explorer.

  19. Expand BLOB CONTAINERS.

  20. Click datafiles and verify the files have been uploaded.

Use AzCopy to Copy Files From the First Storage Account to the Second Storage Account

  1. In the virtual machine, begin entering the AzCopy command.

    azcopy /source:
  2. Return to the Azure portal.

  3. Click Storage accounts from the top of the screen.

  4. Click on the link for the first storage account.

  5. Click Blobs under Blob service.

  6. Click the ellipsis (...) at the end of the datafiles row.

  7. Click Container properties.

  8. Copy the URL.

  9. Return to the virtual machine and paste in the URL for the source.

    azcopy /source:CONTAINER_1_URL
  10. Return to the Azure portal.

  11. Click Storage accounts from the top of the screen.

  12. Click on the link for the second storage account.

  13. Click Blobs under Blob service.

  14. Click the ellipsis (...) at the end of the datafiles row.

  15. Click Container properties.

  16. Copy the URL.

  17. Return to the virtual machine and paste in the URL for the destination.

    azcopy /source:CONTAINER_1_URL /Dest:CONTAINER_2_URL
  18. Return to the Azure portal.

  19. Click Storage accounts from the top of the screen.

  20. Click on the link for the first storage account.

  21. Click Access keys under Settings.

  22. Copy the key under key1.

  23. Return to the virtual machine and paste in the source key.

    azcopy /source:CONTAINER1_URL /Dest:CONTAINER_2_URL /sourcekey:ACCESS_KEY_1
  24. Return to the Azure portal.

  25. Click Storage accounts from the top of the screen.

  26. Click on the link for the second storage account.

  27. Click Access keys under Settings.

  28. Copy the key under key1.

  29. Return to the virtual machine and paste in the destination key.

    azcopy /source:CONTAINER1_URL /Dest:CONTAINER_2_URL /sourcekey:ACCESS_KEY_1 /DestKey:ACCESS_KEY_2
  30. Run the command.

  31. Re-enter the command with the /s option.

    azcopy /source:CONTAINER1_URL /Dest:CONTAINER_2_URL /sourcekey:ACCESS_KEY_1 /DestKey:ACCESS_KEY_2 /s
  32. Run the command again.

Use AzCopy to Copy Files From the Second Storage Account to the Local System

  1. Using Windows Explorer, navigate to the C drive.

  2. Create a new directory and call it "importeddata".

  3. In the command line window, copy files from the second storage account into the local system.

    azcopy /source:
  4. Click Blobs under Blob service.

  5. Click the ellipsis (...) at the end of the datafiles row.

  6. Click Container properties.

  7. Copy the URL.

  8. Return to the virtual machine and paste in the URL for the source.

    azcopy /source:CONTAINER_2_URL
  9. Add the destination.

    azcopy /source:CONTAINER_2_URL /Dest:C:importeddata
  10. Return to the Azure portal.

  11. Click Access keys under Settings.

  12. Copy the key under key1.

  13. Return to the virtual machine and paste in the source key.

    azcopy /source:CONTAINER_2_URL /Dest:C:importeddata /SourceKey:ACCESS_KEY_2
  14. Run the command.

  15. Add the recursive mode and rerun the command.

    
    azcopy /source:CONTAINER_2_URL /Dest:C:importeddata /SourceKey:ACCESS_KEY_2 /s
  16. View the C:importeddata directory and verify the transfer of files.

Conclusion

Congratulations — you've completed this hands-on lab!