Azure Functions for Sql Maintenance-
Trigger: HttpTrigger
Since this is an HTTP-triggered Azure Function, it is manually or programmatically called via an HTTP request
This function uses [AuthorizationLevel.Function], meaning:
- A function key is required to call it.
- You can find the key in Azure Portal → Function App → Functions → ScheduledCleanup → Get Function URL.
Testing via Postman:
Deploy the function.
Copy the Function URL with the key.
In Postman:
Method: POST
URL: https://<your-func-app>.azurewebsites.net/api/ScheduledCleanup?code=<your-key>
No body required.
Send request.
Call Timely basis
You can absolutely call your HTTP-triggered Azure Function every day at 2 AM, but since HTTP-triggered functions are not time-based by default,
you’ll need an external scheduler to trigger it at 2 AM.
Use Azure Logic Apps (No-Code Scheduling)
Go to Azure Portal.
Create a new Logic App (Consumption).
In the designer, add a trigger:
Recurrence → Set to 2 AM daily.
Add an HTTP action:
Method: POST
URL: Your function URL (with ?code=...)
Save.
This will call your Azure Function daily at 2 AM (UTC or set local time in recurrence).