Can we run a stored procedure in Azure SQL Database asynchronously.

Ayush Shrivastava 120 Reputation points
2024-07-15T12:20:11.3033333+00:00

I want to run my stored procedure async using T-SQL. Can we do it ?

Azure SQL Database
{count} votes

3 answers

Sort by: Most helpful
  1. Sedat SALMAN 14,180 Reputation points MVP
    2024-07-15T12:26:38.35+00:00

    Azure Automation allows you to create runbooks that can execute PowerShell scripts or other scripts to run your stored procedures asynchronously

    https://learn.microsoft.com/en-us/answers/questions/1165217/how-schedule-a-sql-query-to-run-every-day-on-azure

    or

    You can use Azure Functions to create a serverless solution that executes your stored procedure based on a timer schedule

    https://learn.microsoft.com/en-us/answers/questions/1165217/how-schedule-a-sql-query-to-run-every-day-on-azure

    and another method is to use service broker


  2. Oury Ba-MSFT 20,911 Reputation points Microsoft Employee Moderator
    2024-07-15T16:42:21.7433333+00:00

    @Ayush Shrivastava Thank you for reaching out.

    In addition to Sedat SALMAN's answer, you could also use ADF and schedule the execution of the procedure. You can create a pipeline with one or more Stored Procedure activities and add a trigger to schedule the pipeline running. see this https://stackoverflow.com/questions/62417858/run-azure-sql-server-stored-procedure-async

    https://learn.microsoft.com/en-us/azure/azure-sql/database/job-automation-overview?view=azuresql

    Regarding the second question,

    By default, job agents are created at JA100, allowing up to 100 elastic job executions concurrently. Initiating a service level change is an asynchronous operation and the new service level will be made available after a short provisioning delay.

    If you need more than 100 concurrent executions of elastic job agents, higher service levels are available, see Concurrent capacity tiers. You can currently change the service level of a job agent via the Azure portal, PowerShell, or REST API.

    Exceeding the service level with concurrent jobs will create queuing delays before jobs start in excess of the service level's concurrent jobs limit.

    0 comments No comments

  3. Oury Ba-MSFT 20,911 Reputation points Microsoft Employee Moderator
    2024-07-17T20:28:35.6933333+00:00

    @Ayush Shrivastava

    Scale up/down can be done through portal as well as PowerShell/REST APIs - https://learn.microsoft.com/en-us/azure/azure-sql/database/elastic-jobs-tutorial?view=azuresql#scale-the-elastic-job-agent-by-using-powershell

     But we don't have an auto scaling feature for Job Agent based on the number of concurrent jobs at this point. Feel free to file a feature request through elastic job · Community (azure.com) for a future release.

    Hope that helps.

    Regards,

    Oury

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.