我有一個天藍色的雲服務,我希望它在作業完成後暫停自己。我有一個可以暫停控制檯應用程序的雲服務的方法(如下所示),但是當我從放置的雲服務中放置方法並調用它時,它不會自行暫停。如何讓Azure Cloud Service使用PowerShell來暫停自己
public void StopService(string serviceName, string email, string password)
{
using (PowerShell script = PowerShell.Create())
{
script.AddScript(string.Format("$password = ConvertTo-SecureString \"{0}\" -AsPlainText -Force", password));
script.AddScript(string.Format("$userName = \"{0}\"", email));
script.AddScript(string.Format("$creds = New-Object System.Management.Automation.PSCredential ($userName, $passwprd)"));
/*Code to sign in to azure subscription
* ...
* ...
*/
script.AddScript(string.Format("$Status = (Get-AzureDeployment -ServiceName \"{0}\").Status", serviceName));
script.AddScript(string.Format("if($Status -eq \"Running\") {1} Get-AzureService -ServiceName \"{0}\" | Stop-AzureService {2}", serviceName, _bracketOpen, _bracketClose));
script.AddScript(string.Format("(Get-AzureDeployment -ServiceName \"{0}\").Status", serviceName));
Collection<PSObject> result = script.Invoke();
}
}
Azure雲服務可以暫停自己,還是需要暫停外部服務?
任何具體理由要它暫停,不會被刪除? –
我有另一個PowerShell腳本等待它從運行轉換爲掛起,然後它啓動其他邏輯 – Paul
您可以在問題中詳細介紹其他邏輯的高級設計概述嗎?它不尋常的工人角色定期啓動和停止... –