Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azcopy error "This request is not authorized to perform this operation."

I copied a container to another storage account based on the document linked below. (DataLake Storage Gen2).

When trying, I got the following error:

this request not authorized to perform this operations using this permission

https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10

like image 670
TA Hyouno Avatar asked Mar 09 '20 14:03

TA Hyouno


People also ask

How do you authenticate with AzCopy?

Authorize a user identity Then, run any azcopy command (For example: azcopy list https://contoso.blob.core.windows.net ). This command returns an authentication code and the URL of a website. Open the website, provide the code, and then choose the Next button. A sign-in window will appear.

How do I run AzCopy in PowerShell?

Run AzCopy If you choose not to add the AzCopy directory to your path, you'll have to change directories to the location of your AzCopy executable and type azcopy or . \azcopy in Windows PowerShell command prompts. As an owner of your Azure Storage account, you aren't automatically assigned permissions to access data.

Does AzCopy create folder if not exists?

AzCopy doesn't create folders that dont exist in the destination file share #1694.

How use AzCopy Linux?

Install and enable the .Once you have installed . NET Core, download and install AzCopy. You can remove the extracted files once AzCopy on Linux is installed. Alternatively if you do not have superuser privileges, you can also run AzCopy using the shell script 'azcopy' in the extracted folder.


7 Answers

If you are using AAD Token, this error is telling you that you need to add a role assignment to the user. Please go to Storage account -> Access Control -> Add -> Add role assignment, then add Storage Blob Data Owner to your login account.

enter image description here

If this problem persists, please provide more details.

like image 144
Cindy Pau Avatar answered Oct 11 '22 16:10

Cindy Pau


Had a similar issue. That's how was resolved

Command used was .\azcopy.exe copy "C:\Users\kriof\Pictures" "https://test645676535storageaccount.blob.core.windows.net/images?sp=rw&st=2022-02-23T11:03:50Z&se=2022-02-23T19:03:50Z&spr=https&sv=2020-08-04&sr=c&sig=QRN%2SMFtU3zaUdd4adRddNFjM2K4ik7tNPSi2WRL0%3D"

SAS token had default(Read) permission only. Adding Write permission in Azure Portal, resolved the issue.

enter image description here

like image 27
Krzysztof Abram Avatar answered Sep 19 '22 22:09

Krzysztof Abram


After granting myself with role Storage Blob Data Owner on the container, then AzCopy will now behave itself and succeed in copying a file to the blob storage container.

go to storageaccount -> container -> Access control rules -> add role assignement -> Storage Blob Data Owner

like image 38
Sajjad Ali Khan Avatar answered Oct 11 '22 17:10

Sajjad Ali Khan


I also faced the same problem. For me to work I just log out and log in again on the azcopy cli after doing the @BowmanZhu solution

azcopy logout
azcopy login --tenant-id xxxx-xxxx-xxxx

If you don't want to login that way there is always the option to add a SAS token at the end of the URL. If you don't want to attach the token always at the end you can try for permanent access by going through any one of these steps you find in the official documentation page.

like image 3
Sulabh Shrestha Avatar answered Oct 11 '22 17:10

Sulabh Shrestha


The SAS token has probably expired.

like image 1
11ohina017 Avatar answered Oct 11 '22 15:10

11ohina017


When I had this, I discovered it was because I'd used Azure Storage Explorer to generate a SAS that didn't have read permission, and I think it was trying to read the size/existence of a blob before writing it.

I got a clue from https://github.com/Azure/azure-storage-azcopy/issues/790 but ultimately I just regenerated a new SAS with read permission and it worked out..

I probably could ahve looked to modify the C# code using Azure Data Movement lib, to not perform a length check, but the spec was later changed to "don't overwrite" so the read permissions are probably needed anyway

like image 1
Caius Jard Avatar answered Oct 11 '22 17:10

Caius Jard


Give appropriate permissions(read, write, create) while generating SAS tokens as here

like image 1
pavan kumar katikam Avatar answered Oct 11 '22 16:10

pavan kumar katikam