Why can't I set env vars in cmd. Unable to use azcopy to copy from S3

Viewed 481

I need to copy an 3S bucket to an Azure blob storage container. I'm trying to use azcopy. However it doesn't work because I cannot set the required AWS keys as env vars.

I have followed this guide: https://www.thomasmaurer.ch/2019/06/migrate-aws-s3-buckets-to-azure-blob-storage/

I set the variables:

set AWS_ACCESS_KEY_ID=<my key>
set AWS_SECRET_ACCESS_KEY=<my secret>

I then use:

azcopy copy <my s3 bucket> <my blob container SAS> --recursive=true

It spits out this:

INFO: Scanning...

failed to perform copy command due to error: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables must be set before creating the S3 AccessKey credential

When I try azcopy env it shows nothing set for the aws key and redacted for the secret:

INFO: Name: AWS_ACCESS_KEY_ID
Current Value:
Description: The AWS access key ID for S3 source used in service to service copy.

INFO: Name: AWS_SECRET_ACCESS_KEY
Current Value: REDACTED
Description: The AWS secret access key for S3 source used in service to service copy.

Any help much appreciated as always!

2 Answers

The solution was to use:

setx AWS_ACCESS_KEY_ID setx AWS_SECRET_ACCESS_KEY

Restarted terminal tried azcopy again and it worked!

I had the same problem when I was setting the AZCOPY_CONCURRENT_FILES variable. Then I figured out you have to set the environment variables as you set them on PowerShell ( with $ sign) .

i.e $env:AZCOPY_CONCURRENCY_VALUE = 256

Have a try following code to set the access key

  • $env:AWS_ACCESS_KEY_ID = <access_key>
  • $env:AWS_SECRET_ACCESS_KEY = <secret_key>
Related