0
我对PowerShell根本没有太多经验 - 我想要做的就是使用我的Azure自动化服务设置一个将自动重新启动的Runbook凌晨1点,每天晚上我的一个Azure网络应用程序。Azure Automation - Runbook每天自动重新启动一个Web应用程序
是否可以使用Powershell/Azure Automation实现此目标?
我对PowerShell根本没有太多经验 - 我想要做的就是使用我的Azure自动化服务设置一个将自动重新启动的Runbook凌晨1点,每天晚上我的一个Azure网络应用程序。Azure Automation - Runbook每天自动重新启动一个Web应用程序
是否可以使用Powershell/Azure Automation实现此目标?
这是完全可能的,你需要创建一个Azure的自动化账号,创建一个运行手册绑在日程安排和使用这样的:
$connectionName = "AzureRunAsConnection" # this is the default connection created when you provision the Automation account,
# you might need to change this to your own connection name
$servicePrincipalConnection = Get-AutomationConnection -Name $connectionName
$null = Add-AzureRmAccount `
-ServicePrincipal `
-TenantId $servicePrincipalConnection.TenantId `
-ApplicationId $servicePrincipalConnection.ApplicationId `
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
$null = Select-AzureRmSubscription -SubscriptionId 'SUB_GUID' ` # Needed if you have more than 1 subscription
Restart-AzureRmWebApp -ResourceGroupName xxx -Name WebAppName