2017-07-29 86 views

回答

2

这是完全可能的,你需要创建一个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