Azure Autimation - Powershell script failing

Nibbler 616 Reputation points
2021-03-31T05:14:07.11+00:00

Hi all,

I have the following PS script, that I want schedule using Azure Automation, is failing saying that "Set-AzureRmAppServicePlan" is not correct. That I dont understand as it works geat when running it in Azure Cloud Shell

Set-AzureRmAppServicePlan -Name "Solution-EUWE" -ResourceGroupName "Shared" -Tier PremiumV2 -NumberofWorkers 1 -WorkerSize "Small"

The error:
Set-AzureRmAppServicePlan : The term 'Set-AzureRmAppServicePlan' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Set-AzureRmAppServicePlan -Name "Solution-EUWE" -ResourceGroupName " ... + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Set-AzureRmAppServicePlan:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,113 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,362 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 96,281 Reputation points MVP
    2021-03-31T08:34:04.093+00:00

    Hi @KE1980 ,

    the cmdlet Set-AzureRmAppServicePlan is part of the AzureRM.Websites module.
    This module is not imported in an Azure Automation Account by default.

    Please try the following steps:

    In the Azure Portal ...

    83235-image.png

    Import the module ...

    83216-image.png

    Now the runbook should work.

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


0 additional answers

Sort by: Most helpful