简体   繁体   中英

Access Azure Blob using Python without Azure Storage Blob package

I need to upload a JSON file to Azure blob using Python, using below code:

from azure.storage.blob import BlobClient

blob = BlobClient(account_url=ACCOUNT_URL,
                  container_name=CONTAINER_NAME,
                  blob_name = folder1/folder2/sample.json,
                  credential=CREDENTIAL)

blob.upload_blob(json.dumps(sample_json),overwrite=True)

This code works well. Only problem is, the package azure.storage.blob installs chardet package which is of LGPL license and its not acceptable for my project. Is there any other way we can upload the data to blob on Azure without using the above mentioned package?

SDKs are simply a wrapper over Azure Storage REST API . If using the SDK is not possible for you, you can write your own code that consumes REST API.

For uploading blob, the REST API operation would be Put Blob : https://docs.microsoft.com/en-us/rest/api/storageservices/put-blob .

Considering the SDKs are open source, you can take a look at the SDK code and see how REST APIs are consumed in the SDK. This is where you can find the source code: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/storage/azure-storage-blob/azure/storage/blob .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM