2017-07-29 88 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