2017-05-05 3 views
1

Restart-Azure Rm Web App PowerShell을 사용하여 웹 응용 프로그램을 다시 시작할 수는 있지만 계획의 모든 서버가 동시에 다시 시작되므로 시스템이 잠시 중단됩니다 .Azure 웹 응용 프로그램에서 고급 응용 프로그램을 다시 시작하기위한 Powershell

Azure 포털에는 개별 인스턴스를 다시 시작하는 사이에 시간 지연을 사용하는 "고급 응용 프로그램 다시 시작"기능이 있습니다.

PowerShell에서 호출 할 수있는 방법이 있습니까?

+0

모든 업데이 트를 내 대답은 도움이/유용하다고 생각합니다. 다른 사람들이 그 혜택을 누릴 수 있도록 답변으로 표시하십시오. –

답변

0

설명에 따르면 Get-AzureRmResource 명령을 사용하여 웹 응용 프로그램에서 각 인스턴스의 프로세스를 먼저 찾을 수 있습니다. 그런 다음 Remove-AzureRmResource를 사용하여 이러한 프로세스를 중지 할 수 있습니다. 그런 다음 하늘빛 웹 응용 프로그램에 액세스하면 하늘빛은 자동으로 응용 프로그램을 실행하기 위해 새로운 인스턴스의 프로세스를 만듭니다.

자세한 내용은, 당신은 파워 쉘 코드 아래를 참조 수 :

Login-AzureRmAccount 
Select-AzureRmSubscription -SubscriptionId '{your subscriptionid}' 

$siteName = "{sitename}" 
$rgGroup = "{groupname}" 

$webSiteInstances = @() 

#This gives you list of instances 
$webSiteInstances = Get-AzureRmResource -ResourceGroupName $rgGroup -ResourceType Microsoft.Web/sites/instances -ResourceName $siteName -ApiVersion 2015-11-01 

$sub = (Get-AzureRmContext).Subscription.SubscriptionId 

foreach ($instance in $webSiteInstances) 
{ 
    $instanceId = $instance.Name 
    "Going to enumerate all processes on {0} instance" -f $instanceId 

    # This gives you list of processes running 
    # on a particular instance 
    $processList = Get-AzureRmResource ` 
        -ResourceId /subscriptions/$sub/resourceGroups/$rgGroup/providers/Microsoft.Web/sites/$sitename/instances/$instanceId/processes ` 
        -ApiVersion 2015-08-01 

    foreach ($process in $processList) 
    {    
     if ($process.Properties.Name -eq "w3wp") 
     {    
      $resourceId = "/subscriptions/$sub/resourceGroups/$rgGroup/providers/Microsoft.Web/sites/$sitename/instances/$instanceId/processes/" + $process.Properties.Id    
      $processInfoJson = Get-AzureRmResource -ResourceId $resourceId -ApiVersion 2015-08-01          

      # is_scm_site is a property which is set 
      # on the worker process for the KUDU 

       $computerName = $processInfoJson.Properties.Environment_variables.COMPUTERNAME 

       if ($processInfoJson.Properties.is_scm_site -ne $true) 
      { 
       $computerName = $processInfoJson.Properties.Environment_variables.COMPUTERNAME 
       "Instance ID" + $instanceId + "is for " + $computerName 

       "Going to stop this process " + $processInfoJson.Name + " with PID " + $processInfoJson.Properties.Id 

       # Remove-AzureRMResource finally STOPS the worker process 
       $result = Remove-AzureRmResource -ResourceId $resourceId -ApiVersion 2015-08-01 -Force 

       if ($result -eq $true) 
       { 
        "Process {0} stopped " -f $processInfoJson.Properties.Id 
       } 
      }  
     } 

    } 
} 

결과 : enter image description here

+0

이것은 좋은 접근법의 실행 가능한 구현입니다. 다행스럽게도 Restart-Azure Rm Web App cmdlet의 옵션 일뿐입니다. –

관련 문제