I am looking to update/overwrite the contents of a simple azure blob that holds a txt file with simple a date string inside. I am using it as a way to store the last run time of a certain process.
I have tried a few methods and had no luck also struggling to find any documentation that will help my cause. Any help or recommendations are appreciated.
import datetime
from azure.storage.blob import BlobServiceClient, BlobClient
maxdate = datetime.datetime.now()
now = maxdate.strftime("%m-%d-%YT%H:%M:%S")
def upload_to_blob(data):
conn_str = "<conn_str>"
blob_service_client = BlobServiceClient.from_connection_string(conn_str)
blob_client = blob_service_client.get_blob_client(container="vstscontainerreleases", blob="last_run.txt")
blob_client.upload_blob(data)
upload_to_blob(now)
I have tried the above simple reuploading the same blob but get an error saying blob already exists.
Time:2021-08-18T11:53:00.0692411Z
ErrorCode:BlobAlreadyExists
Error:None