【问题标题】:Running Set-AzureRmAppServicePlan from Automation script (RunBook)从自动化脚本 (RunBook) 运行 Set-AzureRmAppServicePlan
【发布时间】:2016-01-25 03:29:50
【问题描述】:
我正在尝试从自动化运行手册运行 Set-AzureRmAppServicePlan,但得到了
Set-AzureRmAppServicePlan : 运行 Login-AzureRmAccount 登录。在
行:20 字符:1
+ 设置-AzureRmAppServicePlan -ResourceGroupName "...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Set-AzureRMAppServicePlan], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.Azure.Commands.WebApps.Cmdlets.AppServicePlans.SetAzureAppServicePlanCmdlet
请注意,使用自动化凭据的实际 Runbook 身份验证是成功的。
我可以使用从本地 powershell 运行这个脚本
登录-AzureRmAccount
添加-AzureRmAccount
设置-AzureRmAppServicePlan...
是否有可能在没有交互式登录的情况下从自动化运行它?
谢谢
帕维尔
【问题讨论】:
标签:
powershell
azure
azure-web-app-service
【解决方案1】:
弄清楚.. 很简单,而不是
Add-AzureAccount - 用于自动创建的示例 Runbook Get-AzureVMTutorial
需要使用
添加-AzureRmAccount
用于 Azure 资源管理器 cmdlet 请求,例如
设置-AzureRmAppServicePlan
在这里留下问题/答案..可能仍然可以帮助某人
【解决方案2】:
如果您没有使用 MFA,请查看以下 cmds,将“yourPassword”、“yourUserName”、“yourEnvironment”、“yourSubscriptionId”、“yourTenantId”替换为您自己的消息并将其放入您的脚本中,然后您就可以登录了没有交互式页面。
$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'