0
votes

Am trying to copy the files from AWS S3 to Azure blob. To do that i have used azcopy.

I have downloaded azcopy in my windows machine and accessed it via command prompt.

As needed, i have set my AWS secret key and access key ID in the azcopy env

Now, i can move the files from S3 to blob

But to do that each time am giving the SAS token in the command. Is it possible to hide it or is it possible to pass via a file

cp "https://s3.amazonaws.com/testblobutopud/"   "SAS token" --recursive

I do not need to pass this token directly in command...cAn someone help me in this

Error: enter image description here enter image description here

Environment variable enter image description here

enter image description here

1
what's your real purpose? do you provide this command to others and want to prevent sasToken reveal? or something else?Ivan Yang
yeah, exactly we don't want reveal the SAS token to others @IvanYangKanagam bala
@IvanYang Could u pls help me in this?Kanagam bala
Yes, please see the answer below, and let me know if you have any concerns.Ivan Yang

1 Answers

0
votes

Updated:

please set your sastoken in Environment Variable, like it's name is bloburl_sastoken, and use double quotes to wrap it's value(it's value looks like this: https://blobtestutopus.blob.core.windows.net/?sv=2019-10-10&ss=bfqt&srt=sco&sp=rwdlacupx&se=2020-07-17T10:09:48Z&st=2020-07-17T02:09:48Z&spr=https&sig=xxxxxxxxx).

Then in the command prompt, use the code below:

set temp_chars=""

set temp_url=%temp_chars%%bloburl_sastoken%

set url_sastoken=%temp_url:""=%

azcopy cp "https://s3.amazonaws.com/testblobutopud/" %url_sastoken%

Original answer:

You can store the sasToken in the Environment variable. The steps are as below:

Step 1: Set an Environment Variable, you can use command or UI to do this. Here, I just set it via UI. Note that for it's value, you should wrap the value in double quotes in English mode. The screenshot as below:

enter image description here

Step 2: then open a cmd prompt, and use the code below(please remove the comments section):

//set a variable for the blob url
set url="https://yy1.blob.core.windows.net/test5/myfoo1.txt"

//set a variable which contains blob url and sastoken
set temp_url=%url%%mysastoken%

//remove the redundant double quotes in blob url and sastoken
set url_sastoken=%temp_url:""=%

//copy it
azcopy copy "d:\foo.txt" %url_sastoken%

Another way is that you can use AzCopy login command, then you don't need to use sastoken here.