Hi,
I have written a small python code that reads a file from a blob storage container and appends it in the same container.
When i run it on my local machine, the column names are appended correctly and the code executes without error.
When i deploy it to azure function and then run it from there , i get "HTTP response code 500 Internal Server Error"
I am not proficient in python or azure function but my guess is my binding file is not correctly configured or something else. Would really appreciate if someone could cast an extra pair of eyes and see where i am making a mistake.
Thank you !
-------------------------------------------------PYTHON CODE------------------
import logging
from types import TracebackType
import azure.functions as func
from azure.storage.blob import BlobClient,BlobServiceClient
def main():
try:
logging.info(' start Python Main function processed a request.')
#CONNECTION STRING
blob_service_client = BlobServiceClient.from_connection_string("CONN_STR==;EndpointSuffix=core.windows.net")
# MAP SOURCE FILE
blob_client = blob_service_client.get_blob_client(container="sie", blob="SIE_SHORT.txt")
#SOURCE CONTENTS
content= blob_client.download_blob().content_as_text()
# WRITE HEADER TO A OUT PUTFILE
output_file_dest = blob_service_client.get_blob_client(container="sie", blob="SIEOUTPUT.csv")
#INITIALIZE OUTPUT
output_str = ""
#STORE COULMN HEADERS
data= list()
data.append(list(["COLUMN1", "COLUMN2", "COLUMN3", "COLUMN4"]))
output_str += ('"' + '","'.join(data[0]) + '"\n')
output_file_dest.upload_blob(output_str,overwrite=True)
logging.info(' END OF FILE UPLOAD')
except Exception as ex:
print('Unable to connect!')
print('Exception:')
print(ex)
logging.error(ex)
if name == "main":
main()
----------------------------------------FUNCTION.JSON-------------------
{
"scriptFile": "init.py",
"bindings": [
{
"type": "blob",
"direction": "in",
"name": "blob_client",
"path": "sie/SIE_SHORT.txt",
"connection": "AzureWebJobsStorage"
},
{
"type": "blob",
"direction": "out",
"name": "output_file_dest",
"path": "sie/SIEOUTPUT.csv",
"connection": "AzureWebJobsStorage"
},
{
"name": "$return",
"direction": "out",
"type": "http"
}
]
}
---------------------------------------REQUIREMENT.TXT--------------------------
azure-core==1.17.0
azure-functions==1.7.2
azure-storage-blob==12.8.1