Search code examples
apiazureazure-functionshttp-status-code-503

Is there a way to make APIs temporarily unavailable on Azure?


I'd like to implement a 503 feature for my APIs whenever system is in maintenance so that users get the appropriate HTTP response message. As of now, the way I'm doing this is to store a flag in the database and check it with every API request to see if I should be issuing a 503 error. However, I'm thinking there could be a different way to do this on Azure. Is there any setting I could turn on and off on the portal for this purpose so that I don't need to add another lookup trip to the database? I'm using Azure Functions for my services.


Solution

  • You can simply introduce an AppSetting that you check in your function. And then return a HTTP 503. Additionally you can add a timestamp when your API is back and return that in the HTTP header (Retry-After) with your 503.