I created an Azure function in python to insert data into SQL server. The process was taking around a minute when I was locally testing it. But when I deployed the code, I ended up receiving a 503 error as shown below.
After debugging, I realized the data was successfully persisted in the database (the whole 1 min process), but it's only the response that I get is the error.
So I created a function to just sleep for 30 seconds (after some trial and error) and render a JSON response (check below code).
I get a successful response for 29 seconds or lesser but when I make the sleep to 30 seconds, I get the 503 error
import json
import azure.functions as func
import time
def main(req: func.HttpRequest) -> func.HttpResponse:
data = req.get_json()
data["processed"] = True
time.sleep(30)
return func.HttpResponse(json.dumps(data))
Our services aren't available right now
We're working to restore all services as soon as possible. Please check back soon.

I started with a consumption plan and even changed it to Elastic Premium but the outcome did not change.
In Azure Functions, HTTP Error 503 Service Unavailable can be caused due to few reasons like:

Have a look into the "Diagnose and Solve problems" blade in the Azure Function App and select the "Function app down or reporting" detector.

Also, Microsoft Azure Support will do the analysis to find the root cause on your function app if we send an email at [email protected] with your subscription ID as well as your function app name using function logs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With