2014-09-19 48 views
1

我有一條業務應用程序,我想部署到Windows Azure。該應用程序僅在我們的辦公室需要,以節省成本,我想在辦公時間外打開和關閉Azure網站。如何按計劃開啓和關閉Azure網站?

這是如何實現的?

回答

3

您可以使用Azure自動化(當前處於預覽狀態)執行此操作。要做到這一點,

創建一個Runbook啓動網站。例如,

workflow StartContosoWebsite 
{ 
    $cred = Get-AutomationPSCredential -Name "[email protected]" 

    Add-AzureAccount -Credential $cred 

    InlineScript { 

     Select-AzureSubscription -SubscriptionName "MCT" 

     Start-AzureWebsite -Name "contoso-web" 
    } 
} 

創建Runbook以停止網站。例如,

workflow StopContosoWebsite 
{ 
    $cred = Get-AutomationPSCredential -Name "[email protected]" 

    Add-AzureAccount -Credential $cred 

    InlineScript { 

     Select-AzureSubscription -SubscriptionName "MCT" 

     Stop-AzureWebsite -Name "contoso-web" 
    } 
} 

在自動化帳戶爲您在運行手冊用來啓動和停止網站的憑據創建資產。例如,

enter image description here

然後,對每個運行手冊,確定你希望它運行的時間表。對於您的情況,您需要定義一個日常計劃,每7天運行。使用上面的示例,StartContosoWebsite將在您指定的某個時間星期一上午運行。 StopContosoWebsite將在您指定的某個時間星期五運行。