using AZCOPY with only connectionstring

6.2k views Asked by At

I am provided with only a 'connection string' for azcopy.

Connectionstring: DefaultEndpointsProtocol=https;AccountName=someaccoutname;AccountKey=someaccountkey;EndpointSuffix=core.windows.net
URL: https://someaccoutname.blob.core.windows.net/somename

I do not have a 'sas' token or access to the azure portal to create a sas token'.

How can I use AZCOPY to sync a folder on a VM, to that azure storage account, with only the connection string.

3

There are 3 answers

3
Ivan On

That is simple.

The connection string has 2 information you need. [account] = someaccoutname [acesskey] = somthing like this 2iusdofiausd98273412934213/fsdf23409237409dfoasihdfasir9028742hvhxczoivhsadfSFAOIf34Jq==

azcopy cp https://[account].blob.core.windows.net/folder/subfolder/file.txt?[accesskey from connection string, it ends with ==] c:\temp\
0
Chris On

You can use az storage container generate-sas to generate the SAS token, see https://learn.microsoft.com/en-us/azure/applied-ai-services/form-recognizer/generate-sas-tokens

1
Nikhil VJ On

Use Azure Storage Explorer to download the SAS needed. Download and install it from here.

When it opens, connect to your storage account using the connection string, navigate to the container and keep it selected in the left containers pane.

Bottom left -> change from Properties tab to Actions -> Get Shared Access Signature (that's SAS)

Set the expiry date/time, check on permissions you'll need. (Add, Write etc if you want to upload something, probably Delete as well if you want to over-write older files). Create.

Copy the URL. This will be your destination string, with the SAS included.

Note: if there's a $ sign in it, replace with "%24" - at least for linux that seems to be required.

Now form your azcopy command (uploading a folder here)

azcopy copy --from-to=LocalBlob "localfolder/" "destination-with-sas" --recursive