'Azure function returns 503 after 30 seconds
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 403 error as shown below.
After debugging, I realized the data was successfully persisted in the database(the whole 1 min process) but its 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 403 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 Functions Premium but the outcome did not change.
Solution 1:[1]
In Azure Functions, HTTP Error 503 Service Unavailable can be caused due to few reasons like:
- The backend server returned 503 due to a memory leak/issue in the code.
- Platform issue due to the backend server not running/ allocated
- Function host is down/restarting.

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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | HariKrishnaRajoli-MT |

