Azure function /automation runbook for hosting long running jobs

Azure-learning 56 Reputation points
2022-08-31T03:10:24.553+00:00

I am using Azure function for hosting powershell function which is consuming a lot of time.

This function generally takes 60min to complete ,is there any other way we can host a long running powershell based script/function. or we can use Azure function to achieve this with some modification. What is the suggested way, using automation run book /function/webjobs or durable functions?

I tried to create function app in premium plan. still I am getting 503 error. looks like it is related to memory.

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,936 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,368 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,974 questions
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Maxim Sergeev 6,586 Reputation points Microsoft Employee
    2022-08-31T03:45:32.643+00:00

    Hi @NGaur-3476,

    Have you tried to change SKU worker plan? For example, to this one: Four vCPU/14 GB RAM

    Workers are available in three fixed sizes: One vCPU/3.5 GB RAM; Two vCPU/7 GB RAM; Four vCPU/14 GB RAM

    On the other hand, you could use Azure Automation Account with Hybrid Worker Server roles where you use any size of Azure VMs, especially if you think the problem occurs because of memory.
    https://learn.microsoft.com/en-us/azure/automation/extension-based-hybrid-runbook-worker-install?tabs=windows


  2. Azure-learning 56 Reputation points
    2022-08-31T06:44:19.963+00:00

    @Maxim Sergeev yes , I think just function is not appropriate . because powershell scripts (taking backup ) will consume lot of time and in longer run will create performance issue and will be costly. Is there any suggestion where we can add eventhub or any middle ware can retain data for certain amount and use different function to process it later asyn .

    PCould you please help me if there is any such article/suggestion on this approach .


  3. Maxim Sergeev 6,586 Reputation points Microsoft Employee
    2022-08-31T17:47:55.25+00:00

    @NGaur-3476, it depends on what and how you want to achieve it.
    If you expect to run one huge batch with long-running workflows - I recommend using dedicated instances like Azure VM to execute your scripts. But if could control the flow and split the backup task to multiple instances, you could leverage Function without any problems, but it requires to re-engineer your solution.
    So, summarizing the above, I would suggest switching from Functions to Azure Automation Hybrid Worker Servers, where you will be able to run your flows without limitations (except Powershell or VMs limitations themselves), if your script runs successfully from your laptop, it should be executed from Hybrid Worker Server successfully too.

    0 comments No comments

  4. Maxim Sergeev 6,586 Reputation points Microsoft Employee
    2022-09-04T02:47:37.617+00:00

    Please don't hesitate to mark the post as answered if it is. This helps us and our community.

    0 comments No comments

  5. MughundhanRaveendran-MSFT 12,506 Reputation points
    2022-09-04T16:16:41.713+00:00

    Hi @NGaur-3476 ,

    Thanks for reaching out to Q&A forum.

    For long running functions, I would suggest you to use durable functions as they also have powershell support.
    https://learn.microsoft.com/en-us/azure/azure-functions/durable/quickstart-powershell-vscode

    When the functions is long running, please make sure that it is not hitting the memory and cpu limit. You can confirm this by running the "Function app down or reporting errors" detector available in the Daignose and solve problems blade. Please note that, memory related issues can cause 503 errors.

    Feel free to reach out to me if you have any questions.

    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.