skip to Main Content

I’m trying to use Azure Logic App to create an automation that sets the number of always ready instances to 1 during weekends and back to 3 during working days.
Note that my function app is hosted in an Elastic Premium Plan EP1.
I have been struggling on this task but at the end I was not able to solve it. Also I didn’t find any documentation for creating this automation.
Do you have any idea if it is possible to do this?

Function page for scaling out

2

Answers


  1. Chosen as BEST ANSWER

    For the sake of completeness, in the following, a configuration that sets the number of always ready instances to 3 during business hours of week days, and 1 always ready instance during weekend days and out of business hours:

    Logic App condition


  2. After reproducing from my end, I could get this done using Azure Automation Account. I have set the days that I wanted in Logic Apps and made a call to execute the below script based on the day.

    First of all navigate to the "Automation Accounts" service from the console, if you don’t have any automation accounts yet, create one pressing the button "create":

    Automation account creation

    Then you create two runbooks under "Process Automation" section:

    runbooks creation

    Using this PowerShell scripts:

    runbook1 script for Weekdays

    $resourceGroupName = "<YOUR_RESOURCE_GROUP>"
    $functionApp = "<FUNCTION_APP>"
    
    $Resource = Get-AzResource -ResourceGroupName $resourceGroupName -ResourceName $functionApp/config/web -ResourceType Microsoft.Web/sites
    $Resource.Properties.minimumElasticInstanceCount = 3
    $Resource | Set-AzResource -Force
    

    runbook2 script for Weekends

    $resourceGroupName = "<YOUR_RESOURCE_GROUP>"
    $functionApp = "<FUNCTION_APP>"
    
    $Resource = Get-AzResource -ResourceGroupName $resourceGroupName -ResourceName $functionApp/config/web -ResourceType Microsoft.Web/sites
    $Resource.Properties.minimumElasticInstanceCount = 1
    $Resource | Set-AzResource -Force
    

    Don’t forget to "save" and then "publish" the runbooks.

    Save and then publish the runbook

    Then navigate to Logic apps service from the console and create a new instance, then go to "logic apps designer".
    Here is the flow of my logic app:

    enter image description here

    In the True and False boxes search for "create job":

    create job

    Note that when you create the job, you will need to authenticate using one of the available authentication metodologies, I have selected "OAuth default", then you simply paste the tenantID of your subscription.

    enter image description here

    Results:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search