Created
June 6, 2020 06:02
-
-
Save goldsail/ca86edcf3c2765ad2be8ae8e0649d036 to your computer and use it in GitHub Desktop.
Azure REST API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
import io | |
import requests | |
content = 'hello' | |
filename = 'test.txt' | |
account = 'example' | |
container = 'default' | |
blob_type = 'BlockBlob' | |
# This token can be obtained from Azure Portal -> Storage Account -> Shared access signature | |
token = r'?sv=2019-10-10&ss=b&srt=o&sp=rwdlacx&se=2021-07-01T06:59:59Z&st=2020-06-06T05:20:31Z&spr=https&sig=[YOUR_SIGNATURE_HERE]' | |
url = f'https://{account}.blob.core.windows.net/{container}/{filename}' | |
headers = { | |
'Content-Length': str(len(content)), | |
'Content-Type': 'text/plain', | |
'x-ms-blob-type': 'BlockBlob' | |
} | |
resp = requests.put(url + token, headers=headers, data=content) | |
print(resp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment