【发布时间】:2017-11-15 02:23:47
【问题描述】:
如何在 Azure 的 ARM 订阅中的自动化帐户中的 Runbook 中从 Azure 的 Powershell 重新启动 AppService?
我认为方法是:
Restart-AzureWebsite -Name "your-appservice-name"
但是得到:
Restart-AzureWebsite : No default subscription has been designated.
Use select-AzureSubscription -Default #<subscriptionName> to set the default subscription.
Azure PowerShell 中没有可用的 Restart-AzureRmWebApp。
以下所有组合都会导致一堆其他错误消息:
$Cred = Get-AutomationPSCredential -Name 'your-credentials-name'
Add-AzureAccount -Credential $Cred
Add-AzureRMAccount -Credential $Cred
Get-AzureSubscription –SubscriptionName 'your-subscription-name' | Select-AzureSubscription -Default
Restart-AzureWebsite -Name "your-appservice-name"
【问题讨论】:
-
Restart-AzureWebsite这是一个经典的 cmdlet。您的 Azure Power Shell 的版本是什么?Get-Module -ListAvailable -Name Azure -Refresh -
该命令甚至无法在 Azure Powershell 中运行;它返回:Runbook 作业尝试了 3 次,但每次都失败。 Runbook 作业失败的常见原因可在此处找到:docs.microsoft.com/en-us/azure/automation/…
-
在runbook中,需要导入模块
AzureRM.Websites,docs.microsoft.com/en-us/azure/automation/… -
Import-Module AzureRM.Websites 导致:Import-Module :未加载指定的模块“AzureRM.Websites”,因为在任何模块目录中都找不到有效的模块文件。
-
您好,您只需将模块导入您的自动化帐户,然后您就可以使用 cmdlet。无需在 Runbook 中使用
Import-Module AzureRm.Websites。
标签: powershell azure azure-web-app-service