I'm trying to append new lines of json to existing json file in container. Below is my code:
import json
import os
from azure.storage.blob import (
BlockBlobService, AppendBlobService
)
from DBConnection import account_name, container_name, account_key
def getData(self, resp, filename):
blobService = BlockBlobService(account_name=account_name, account_key=account_key)
appendblobservice = AppendBlobService(account_name=account_name, account_key=account_key)
resp = json.dumps(self.resp) #CONVERT FROM DICT TO STR
filename = self.filename + ".json" #eg: 'ww1_abcded_202002031100.json'
file_exist = blobService.exists(container_name, filename)
if file_exist is False:
print("inside IF")
blobService.create_blob_from_text(container_name, filename, self.resp)
else:
print("Inside else")
appendblobservice.append_blob_from_text(container_name, filename, self.resp)
print("2345675t43")
I'm getting error at append_blob_from_text and producing the following error:
azure.common.AzureConflictHttpError: The blob type is invalid for this operation. ErrorCode: InvalidBlobType
InvalidBlobTypeThe blob type is invalid for this operation.