I am using the Azure Blob Storage python
SDK and trying to generate a sas token for my blob, however I keep getting a TypeError
.
This is how I’m calling the built-in function (generate_blob_sas
).
sas_blob = generate_blob_sas(account_name= account_name,
container_name= container_name,
blob_name= blob,
account_key= account_key,
#For writing back to the Azure Blob set write and create to True
permission=BlobSasPermissions(read=True, write= False, create= False),
#This URL will be valid for 2 hour
expiry=datetime.utcnow() + timedelta(hours=2))
I am quite sure all the input variables are correct, as I have used them all throughout my app for other functions provided by the SDK.
The error I am getting is this:
"TypeError: Object of type set is not JSON serializable"
I am wondering if anyone has come across this when using the python SDK for Azure Blob or if anyone has any suggestions on what might help.
Thanks,
Robert
2
Answers
Looks like it was a problem with my environment variables in the end. Thanks to everyone who tried to help.
After reproducing from our end, The code that you have provided works fine whereas you are receiving
"TypeError: Object of type set is not JSON serializable"
because at some point of code you are trying to convert a "set" type object into JSON. Since the JSON encoder handles list values, you can use the list while converting. You can refer Borislav Hadzhiev’s – Object of type set is not JSON serializable for more information.