5

I've download Azure SDK for python to my Ubuntu (Tool version 0.8.16). And i'm trying to run this code

from azure.storage import BlobService blob_service = BlobService(account_name='Real_Name', account_key='Real_Key') blob_service.create_container('mycontainer') blob_service.create_container('mycontainer', x_ms_blob_public_access='container') blob_service.put_block_blob_from_path( 'mycontainer', 'myblob', 'sunset.png', x_ms_blob_content_type='image/png' ) 

I've saved it under Test.py and i'm trying to run it with

python Test.py 

in terminal and i get this error

Traceback (most recent call last): File "Test.py", line 3, in <module> blob_service.create_container('mycontainer') File "/home/parallels/azure-sdk-for-python/azure/storage/blobservice.py", line 203, in create_container _dont_fail_on_exist(ex) File "/home/parallels/azure-sdk-for-python/azure/__init__.py", line 525, in _dont_fail_on_exist raise error azure.WindowsAzureError: Unknown error (Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.) <?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:98ce37f9-0001-003f-350e-7d3666000000 Time:2015-03-24T10:07:00.3385327Z</Message><AuthenticationErrorDetail>Request date header too old: 'Tue, 24 Mar 2015 09:06:59 GMT'</AuthenticationErrorDetail></Error> 

How to fix this, and am i do everything right?

Thanks

2 Answers 2

10

I get similar errors due to clock skew after resuming WSL 2 (Windows Subsystem for Linux) sessions from sleep then using the Azure cli from the bash/zsh command line. This fixes the clock:

sudo hwclock -s -v 

See: Fixing clock skew with WSL 2

Update: This bug seems to be fixed in WSL kernel version 5.10.16.3-microsoft-standard-WSL2. After upgrading, I haven't seen it. See: https://github.com/microsoft/WSL/issues/5014#issuecomment-605243281

Sign up to request clarification or add additional context in comments.

Comments

6

As mentioned in the error:

Request date header too old: 'Tue, 24 Mar 2015 09:06:59 GMT'

You will get this error if difference between the date/time on your computer (in UTC) and date/time on Azure Storage Server is more than 15-20 minutes (your computer's date/time is behind that of Azure).

UPDATE

Essentially what happens is that when a request is sent to Azure Storage Service (e.g. create container) the SDK takes the local date/time of your computer, converts it into UTC and then sends it to Azure along with the request (as a request header either date or x-ms-date). Upon receiving the request, among other things Azure Storage service compares this date/time with its date/time and if the difference is more than 15-20 minutes (your clock is behind), Azure Storage service throws the error you're getting. This is done as a security measure so that in case somebody got hold of your request can't replay the request over and over again.

5 Comments

So this Request date header too old: 'Tue, 24 Mar 2015 09:06:59 GMT Is time of my Azure Storage Server?
No. It is the time on your computer in GMT/UTC. Please see my updated answer.
Thank you! But is there a way to check Azure storage time?
Directly no. But one of the response headers include Azure Storage date/time value. Not sure how you would extract this information from Python SDK. However you could simply check out current GMT time here: wwp.greenwichmeantime.com and compare it with time on your computer to see if your computer's clock is indeed running behind.
Thanks for this answer! I was having the same error locally and it turns out my VM didn't update with the recent DST change, so I was an hour off from Azure's time and couldn't upload anything.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.