1
votes

I created the step in Azure Devops to Start and Stop IIS Website but it is failing with below error message:

**2020-05-23T10:28:04.7393424Z ##[section]Starting: Start 2020-05-23T10:28:04.7659676Z

2020-05-23T10:28:06.5436980Z ##[command]"C:\Windows\system32\inetsrv\appcmd.exe" start site /site.name:"taxrpt-deva" 2020-05-23T10:28:06.6132349Z ERROR ( message:The W3SVC service is not available - try starting the service first. ) 2020-05-23T10:28:06.7434786Z ##[error]Process 'appcmd.exe' exited with code '50'. 2020-05-23T10:28:06.7680874Z ##[section]Finishing: Start **

Azure IIS Web App Manage Screen Shot

2
Is there a way to clean up the website directory before deploying?Paras
Cleanup shouldn't be necessary if we are able to gracefully shutdown the site for a moment and replace new DLLs if its .NET Core app and for legacy .NET Framework application we can easily replace the DLLs in most cases even though the application is running.sapatelbaps
IIS web app management task is a Deprecated task, try to use task WinRM - IIS Web App Management: github.com/microsoft/azure-pipelines-extensions/blob/master/…Leo Liu-MSFT
How about the issue? Does the answer below resolved your question, If not, would you please let me know the latest information about this issue?Leo Liu-MSFT
Thanks Leo @LeoLiu-MSFT. I configured with WinRM and its works as espected. Appreciate for your help!!Paras

2 Answers

2
votes

How to Start/Stop IIS on the target Windows server before deployment in Azure Devops Pipeline

According to the image you provided, you are using the Deprecated task IIS Web App manage:

enter image description here

To resolve this issue, please try to use the task WinRM - IIS Web App Management.

Hope this helps.

0
votes

As per the first line of question, you want to stop the IIS website infact rather than IIS.

The simplest way is to create a blank file 'App_Offline.htm' in the deployment directory. Official reference link.

I assume that as you want to stop the IIS/webapp you should have access of the deployment directory. This approach should work even if your azure devops Agent is running on other network machine. This file will shutdown your application and after deploying the build artifacts you may run powershell command task to delete that file from the shared directory like shown in the sample:

enter image description here