You could use Azure Functions, or look at Azure Automation (https://learn.microsoft.com/en-us/azure/automation/overview).
Azure Automation has Hybrid Worker - which allows you to run tasks - https://learn.microsoft.com/en-us/azure/automation/automation-hybrid-runbook-worker - on a server in your environment.
Depending on the complexity and requirements.