I'm trying to create an Azure automation system to change the number of always ready instances of a Function App (the App Service Plan is Elastic Premium One EP1):
The Automation System is created in order to set the number of Always Ready Instances to 3 during week days, and set it to 1 during weekend days.
The System is composed by the following two runbooks created under the service Azure Automation Accounts:
- "runbook-Weekdays"
$resourceGroupName = "xxxxxxxxxxxx"
$functionApp = "xxxxxxxxxx-func"
$Resource = Get-AzResource -ResourceGroupName $resourceGroupName -ResourceName $functionApp/config/web -ResourceType Microsoft.Web/sites
$Resource.Properties.minimumElasticInstanceCount = 3
$Resource | Set-AzResource -Force
- "runbook-Weekend-days"
$resourceGroupName = "xxxxxxxxxxxx"
$functionApp = "xxxxxxxxxxxx-func"
$Resource = Get-AzResource -ResourceGroupName $resourceGroupName -ResourceName $functionApp/config/web -ResourceType Microsoft.Web/sites
$Resource.Properties.minimumElasticInstanceCount = 1
$Resource | Set-AzResource -Force
Note that I'm using a "System Assigned" identity in my Automation Account.
While the automation logic is implemented using Azure Logic Apps:
Where the expression under the "Condition" box is: formatDateTime(utcNow(),'dddd')
, which set only for the week days as can be seen from the previous figure.
The following figure is the second part of the Logic App:
Note that, when creating the Automation Job in Logic Apps, I have selected "OAuth default" as authentication method, then I simply pasted the tenantID of my subscription.
Now, if I test the Logic App from the Logic App service, it works:
And I would expect a number of always ready instances equal to 3, but if I check the number of always ready instances, nothing changed:
Also, going to the errors page of the runbook page:
I see the following two errors:
Get-AzResource : Run Connect-AzAccount to login. At line:4 char:13 + $Resource = Get-AzResource -ResourceGroupName $resourceGroupName -Res ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Get-AzResource], PSInvalidOperationException + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceCmdlet
and
The property 'minimumElasticInstanceCount' cannot be found on this object. Verify that the property exists and can be set. At line:5 char:1 + $Resource.Properties.minimumElasticInstanceCount = 3 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound
Do you know what could be the problem?