Search code examples
powershellazureazure-web-app-serviceappveyor

Restart Azure web app (aspnet5 rc1-final) deployed using Appveyor


I'm using Appveyor to deploy my aspnet5 (rc1-final) site to an Azure web app (site) using Web deploy. The deployment step works fine but I need to restart the site manually using the Azure portal and that is pretty annoying.

What I have read is that the web app does not restart automatically?

I have tried to use powershell to restart the site but it doesn't seem to work, or I'm doing something wrong?

This is the powershell script I use atm.

after_deploy:
 - ps: Disable-AzureDataCollection
 - ps: Select-AzureSubscription -Current -SubscriptionName "Visual Studio Premium with MSDN"
 - ps: Restart-AzureWebsite -Name "sitename"

I tried using just - ps: Restart-AzureWebsite -Name "sitename" but Azure complained about the subscription name so I added that. I'm using Visual Studio Premium with MSDN it's pretty obvious that it does not work as subscription name?

Select-AzureSubscription : The subscription name Visual Studio Premium with MSDN doesn't exist.

Is it possible to restart the site using powershell or is this a dead end?


Solution

  • You are using the old PowerShell CmdLets. Please install the latest, which is currently 1.0.1.

    With the latest, the CmdLet you want to run is:

    Restart-AzureRmWebApp YourResourceGroup YourWebApp
    

    As for authentication from a CI server, the recommended approach is to use a Service Principal. See this post for details.