0
votes

I'm trying to run Set-AzureRmAppServicePlan from automation runbook but getting

Set-AzureRmAppServicePlan : Run Login-AzureRmAccount to login. At line:20 char:1 + Set-AzureRmAppServicePlan -ResourceGroupName "... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Set-AzureRMAppServicePlan], PSInvalidOperationException + FullyQualifiedErrorId : InvalidOperation,Microsoft.Azure.Commands.WebApps.Cmdlets.AppServicePlans.SetAzureAppServicePlanCmdlet

Note that actual runbook authentication using Automation Credential is successful. And I can run this script from local powershell using Login-AzureRmAccount Add-AzureRmAccount Set-AzureRmAppServicePlan...

Is it possible at all to run this from automation without interactive login? Thanks Pavel

2

2 Answers

0
votes

figure it out.. pretty simple instead of

Add-AzureAccount - which is used in sample runbook Get-AzureVMTutorial created automatically

need to use

Add-AzureRmAccount

for use with Azure Resource Manager cmdlet requests like Set-AzureRmAppServicePlan

Leaving question / answer here.. might still help someone

0
votes

If you are not using MFA, pls see the following cmds, replace 'yourPassword', 'yourUserName', 'yourEnvironment', 'yourSubscriptionId', 'yourTenantId' with your own message and put it to your script then you can login without interactive page.

$userPassword = ConvertTo-SecureString -String "yourPassword" -AsPlainText -Force
$psCred = new-object -typename System.Management.Automation.PSCredential -argumentlist 'yourUserName', $userPassword
$credential = Get-Credential -Credential $psCred
add-azureRmAccount -EnvironmentName 'yourEnvironment' -credential $credential -subscriptionId 'yourSubscriptionId' -tenant 'yourTenantId'