How to Solve AzCopy Error: This request is not authorized to perform this operation
If you are using AzCopy, a command-line tool that allows you to copy files to and from Azure storage, you may encounter the error message “This request is not authorized to perform this operation” when trying to copy files. This error indicates that you do not have the required permissions to access the source or destination storage account. In this blog post, we will explain the possible causes and solutions of this common AzCopy error.
What Causes AzCopy Error: This request is not authorized to perform this operation?
There are several possible causes of AzCopy error: This request is not authorized to perform this operation, such as:
- The source or destination storage account is protected by a firewall or a virtual network (VNet) that blocks your access.
- The source or destination storage account requires authentication with a shared access signature (SAS) token or an Azure Active Directory (AAD) token that you do not have or have expired.
- The source or destination storage account has a blob container or a file share that has a public access level of None, which means that only the owner of the account can access it.
- The source or destination storage account has a blob container or a file share that has a public access level of Blob or Container, but you are trying to copy files other than blobs, such as tables or queues.
How to Solve AzCopy Error: This request is not authorized to perform this operation?
Depending on the cause of the error, there are different ways to solve AzCopy error: This request is not authorized to perform this operation. Here are some of the most common solutions:
- Allow your IP address or VNet in the firewall settings of the source or destination storage account. To do this, go to Azure portal > Storage accounts > Select your storage account > Settings > Firewalls and virtual networks > Add your IP address or VNet > Save.
- Generate and use a SAS token or an AAD token for authentication with the source or destination storage account. To generate a SAS token, go to Azure portal > Storage accounts > Select your storage account > Shared access signature > Configure the parameters > Generate SAS and connection string. To generate an AAD token, go to Azure portal > Storage accounts > Select your storage account > Access keys > Copy one of the key values. To use a SAS token or an AAD token with AzCopy, append it to the source or destination URL as a query parameter. For example:
1 2 |
azcopy copy "https://sourceaccount.blob.core.windows.net/container1?sv=2019-12-12&ss=bfqt&srt=sco&sp=rwdlacupx&se=2023-07-17T20:16:35Z&st=2023-07-17T12:16:35Z&spr=https&sig=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "https://destinationaccount.blob.core.windows.net/container2?sv=2019-12-12&ss=bfqt&srt=sco&sp=rwdlacupx&se=2023-07-17T20:16:35Z&st=2023-07-17T12:16:35Z&spr=https&sig=yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" |
1 2 |
azcopy copy "https://sourceaccount.file.core.windows.net/share1" "https://destinationaccount.file.core.windows.net/share2" --source-key xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --destination-key yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy |
- Change the public access level of the blob container or the file share in the source or destination storage account. To do this, go to Azure portal > Storage accounts > Select your storage account > Blob service > Containers > Select your container > Change access level > Select Blob or Container > Save. Or go to Azure portal > Storage accounts > Select your storage account > File service > File shares > Select your share > Change access level > Select Public read access for files only or Public read/write access for files only > Save.
- Copy only blobs if the blob container or the file share in the source or destination storage account has a public access level of Blob or Container. To do this, use the –blob-type parameter with AzCopy and specify BlockBlob, PageBlob, or AppendBlob. For example:
1 2 |
azcopy copy "https://sourceaccount.blob.core.windows.net/container1" "https://destinationaccount.blob.core.windows.net/container2" --blob-type BlockBlob |