Azure / azure-storage-azcopy

The new Azure Storage data transfer utility - AzCopy v10
MIT License
614 stars 222 forks source link

AzCopy fails intermittently to upload file to Azure Storage #2831

Closed andreiv3103 closed 1 month ago

andreiv3103 commented 1 month ago

Hello!

I am using AzCopy to upload intune Win32 application packages. It works most of the time, but sometimes the upload fails like this:

Uploading the package using 'azcopy.exe' ...
INFO: Scanning...
INFO: Any empty folders will not be processed, because source and/or destination doesn't have full folder support

Job 0649ed24-344d-c84f-6f09-304179f7df3a has started
Log file is located at: D:\Repositories\MDM-Team\Application Packaging\Packages\Windows Autopilot\Autopilot ESP Package - [HAADJ] - [TEST]\logs\0649ed24-344d-c84f-6f09-304179f7df3a.log

INFO: Authentication failed, it is either not correct, or expired, or does not have the correct permission PUT https://mmcswdb02.blob.core.windows.net/29214d0a-c5a3-48cf-aa23-596b047e349d/7d2ea6c9-bb37-4bf6-b20c-0c6ebb19bd91/5f4fced9-be82-4b9b-814f-b21d5acc723b.intunewin.bin
--------------------------------------------------------------------------------
RESPONSE 403: 403 Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
ERROR CODE: AuthenticationFailed
--------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:23e2724b-801e-0010-2837-1ec27f000000
Time:2024-10-14T12:51:08.4881941Z</Message><AuthenticationErrorDetail>SAS identifier cannot be found for specified signed identifier</AuthenticationErrorDetail></Error>
--------------------------------------------------------------------------------

0.0 %, 0 Done, 0 Failed, 1 Pending, 0 Skipped, 1 Total, 2-sec Throughput (Mb/s): 308.6083

Any idea what could cause this? The SAS URL is generated right before the upload, so I don't think it it a time issue. All this happens from PowerShell script. As I said, it is intermittent. What I tried, as suggested by ChatGPT, is to re-sync the clock. And after such a failure (2 failures one after the other) the time re-sync seems to have worked, because the 3rd try went through. Could this really be just a time skew issue?

Or perhaps I need to wait after the SAS url is generated and not try immediately?

andreiv3103 commented 1 month ago

Just tested again. Same behavior. Tried 2 times, with the error above. Time sync - tried again - it worked. The strange part is though that from the Intune console it works without any errors when I upload the intunewin file. But I need to do it from a script. And azcopy is way faster.

andreiv3103 commented 1 month ago

And another test. 2 failures. Time sync. Tried again, it works.

andreiv3103 commented 1 month ago

I found a workaround. If I add a 30 second pause before attempting the upload, it works every time.

ashruti-msft commented 1 month ago

The SAS token is valid for a certain time range only which you can set, seeing that re-syncing clock worked for you is it possible the clock was time was not correct when you ran the command? Great to know you found a workaround, maybe you can also try Microsoft Entra ID for auth.

To investigate further what's the exact reason for this, please share your DEBUG logs, thanks!