none
Restart Webapp - Runbook RRS feed

  • Question

  • Hello,

    Im searching for a runbook for restarting Webapps. If it´s possible setting by tag

    Any ideas?

    Thanks in advance


    • Edited by exitista Tuesday, August 13, 2019 9:36 PM
    Tuesday, August 13, 2019 9:25 PM

Answers

  • Hi exitista,

    If you want to restart all web apps that are having a particular tag then below is the Az PowerShell command to accomplish the requirement. 

    Get-AzResource -Tag @{"xxxxxxx"="yyyyyyy"} -ResourceType "Microsoft.Web/sites"|%{Restart-AzWebApp -ResourceGroupName $_.ResourceGroupname -Name $_.Name}

    Note1: tag name in the above illustration is xxxxxxx and corresponding tag value is yyyyyyy.

    In case you want to restart all web apps that are having particular multiple tags then below is the Az PowerShell command to accomplish the requirement.

    Get-AzResource -Tag @{"xxxxxxx"="yyyyyyy";"aaaaaaa"="bbbbbbb"} -ResourceType "Microsoft.Web/sites"|%{Restart-AzWebApp -ResourceGroupName $_.ResourceGroupname -Name $_.Name}

    Note2: tag name in the above illustration is xxxxxxx and corresponding tag value is yyyyyyy. Similarly aaaaaaa and bbbbbbb are another tag's key value pair.

    Note3: Make sure you import the latest Az.Resources Az.Resources and Az.Websites Az.Websites modules and their dependencies under your Automation account from where you would have a runbook for this requirement.

    Hope this helps!!


    Wednesday, August 14, 2019 7:44 AM
    Moderator