Home can't connect to azure file service REST api by python
Reply: 0

can't connect to azure file service REST api by python

user9647 Published in September 19, 2018, 9:09 am

I want to access my file service by python Request, guided by the list shares page, I'm new to REST and python Request. my input is

headers= {'x-ms-date': '2018-04-17 06:22:15.181620', 'Authorization': 'SharedKey zedongstorageaccount:codecodecodeFiTzubX9tvC3G3PcDYzR2cX/TMjkOu4JhsvQffS+xTDDBQ==', 'x-ms-version': '2017-07-29'}
url = 'https://zedongstorageaccount.file.core.windows.net/?comp=list'

But get error, the output of r.content:

b'\xef\xbb\xbf<?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.\nRequestId:ef98f282-f01a-0042-3e24-d62397000000\nTime:2018-04-17T08:16:21.9635335Z</Message><AuthenticationErrorDetail>The Date header in the request is incorrect.</AuthenticationErrorDetail></Error>'

I have also try the header {'x-ms-date': '2018-04-17 06:22:15.181620', 'Authorization': 'SharedKey zedongnewstorageaccount:NJYYtabOIj5D1R+xb0PpmXrjCldf6NA6oLkYReAKFiTzubX9tvC3G3PcDYzR2cX/TMjkOu4JhsvQffS+xTDDBQ==', 'x-ms-version': '2017-07-29'}, because i don't know if the Authorization and account in the same line. I also tried many version of x-ms-version. But there all the 400 or 403 respond.

I have read the Authentication for the Azure Storage Services but confused.

Where is the error? And is there case I can learn to build my app by Azure REST API?(I use the keyword to google, all the pages are about build REST API and azure official docs)

share|improve this question
  • Are you using account key in the Authorization header? – Gaurav Mantri Apr 17 at 9:48
  • yes, account storage key. Does it wrong? What should I use? – 张泽栋 Apr 17 at 10:47
  • 2
    Yes, it is incorrect. You will actually need to compute the authorisation header steps for which is outlined here: docs.microsoft.com/en-us/rest/api/storageservices/…. I'm just curious as to why you're not using Python SDK for Azure Storage instead of using REST API directly? – Gaurav Mantri Apr 17 at 11:05
  • Gaurav is right, why not use Python SDK instead of calling REST API directly? github.com/Azure/azure-storage-python – Zhaoxing Lu - Microsoft Apr 17 at 11:18
  • 1
    @张泽栋 you have samples which are available in Azure Storage Python SDK GitHub repo github.com/Azure/azure-storage-python/tree/master/samples/file – Ivan Ignatiev - MSFT Apr 17 at 14:56

1 Answer 1

active oldest votes
up vote 2 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.481852 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO