My azure function returns 404 as response code and so the function fails when running in ADF. I am using async mode to delete more than 500 entries in a single Azure table on a single partition key. Normal delete operation takes more time and thus I am using async mode. Using application insight I found this below error multiple times in a single execution.
Response status: 404 Response headers: 'Cache-Control': 'no-cache' 'Transfer-Encoding': 'chunked' 'Content-Type': 'application/json;odata=minimalmetadata;streaming=true;charset=utf-8' 'Server': 'Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0' 'x-ms-request-id': 'bde48b8f-4002-001b-3909-fb4af5000000' 'x-ms-client-request-id': '6227df30-66fc-11ed-82c7-00155d0d9b07' 'x-ms-version': 'REDACTED' 'X-Content-Type-Options': 'REDACTED' 'Date': 'Fri, 18 Nov 2022 04:49:58 GMT'
Code sample
#Import libraries
#Followed by code to load the file from ADLS as a dataframe
#Then the dataframe is converted into list named customer_list
@app.post('/Trigger_CS_deletion/')
async def execute_queries(dummies= None):
start = datetime.datetime.now()
await delete_data()
end = datetime.datetime.now()
time_taken = end -start
time_taken = str(time_taken.total_seconds()) + " seconds"
return {"Time taken to execute the queries" : time_taken}
async def delete_data():
credential = AzureNamedKeyCredential(STORAGE_ACCOUNT_NAME, STORAGE_ACCOUNT_KEY)
table_client = TableClient(endpoint=STORAGE_ACCOUNT_NAME+".table.core.windows.net", table_name=TABLE_NAME, credential=credential)
delete_tasks = [table_client.delete_entity(partition_key=str(0), row_key=c) for c in customer_list]
await asyncio.wait(delete_tasks)
await table_client_trend.close()
async def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse:
return func.AsgiMiddleware(app).handle(req, context)
if __name__ == "__main__":
asyncio.run(main())
Error message from ADF
]1
ADF settings: where function name is the name of the function created inside my function app

However, when the URL is triggered locally from browser the code works fine and gives me the following message

Any advise on how to solve this ?