I am trying to get an Az Function to return an HTTP response and continue a background thread after. In the code below I try to use a thread but the response is still waiting for the function to finish before returning. Is there something I am missing?
import logging
import json
import threading
import azure.functions as func
from .commands import start_process
def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')
    command = req.params.get('command')
    vm = req.params.get('vm')
    if not command:
        try:
            req_body = req.get_json()
        except ValueError:
            pass
        else:
            command = req_body.get('command')
            vm = req_body.get('vm')
    if command == 'restart':
        thread = threading.Thread(target=start_process(vm, command))
        thread.start()
    if command:
    return func.HttpResponse(f"Hello {command}!")
else:
    return func.HttpResponse(
         "Please pass a name on the query string or in the request body",
         status_code=400
    )
 
    