autostart website after web deploy - iis

I have a IIS website with multiple application connected to the same app pool and I deploy regularly some of those website through web deploy with the msdeploy tool. One of this app is set to autostart with the serviceAutoStartEnabled="true" and a matching serviceAutoStartProvider.
It works well when I restart the whole app pool but the autostart is not triggered when I web deploy the website
Is there any way to tell IIS to "restart" fully the website after the deploy and not wait for the first request to it ?

You could use a post sync command:
msdeploy -verb:sync -preSync:runCommand="net stop w3svc" -source:webserver60 -dest:auto,computername=serverA -verbose -postSync:runCommand="appcmd start site /site.name: contoso"
https://technet.microsoft.com/en-us/library/ee619740(v=ws.10).aspx

Related

.NET Website hosted on Azure Windows VM - IIS Web Server fails to work after Server (VM) restart

Hosted a .NET 6 basic Web App in IIS Web Server inside the Azure Virtual Machine (Windows 2016 Data Center)
Commands:
dotnet new webapp
dotnet run
dotnet publish -c Release
3rd command is used for placing release folder files in the Site Physical Path created in IIS Web Server:
It shown the result as welcome page. After VM Stop and Start action, it is showing the localhost as "The Site can't be reached"
If I create new site on Connections of the IIS Manager, then it is working.
Every time after restarting the VM, Creating New Site is not the solution.
Why previously created Site is showing me "The Site can't be reached" error.
What I have tried:
Tested by creating new Site in Connections of the IIS Manager, it worked for the new site but after restarting the VM, it also stopped working and showing above mentioned error.
Checked VM Status, it is Healthy
All required tools are installed in the VM (VS Code, .NET 6 SDK, Runtime, and Hosting Bundle)
Note: It is working successfully after I clear the cache in the browser after server restart (stop and start) but why I have to clear the browser cache every time after VM stop and start?
Update:
Forgot to mention this:
I have given HTTPS binding to the IIS Manager Website Hosted so if do localhost with port 80, it will shows IIS Web Served Home Page and localhost with Https (443), it will show the hosted website content.
After Server Stop and Start, localhost with port 80 gives the IIS Web Served Home Page and localhost with Https is not giving the website content, here it is giving error "The site is not reached".
Fix:
I have found the fix to this issue which is:
Hosting works with particular time period.
Every time when you launch the Website hosted in VM through IIS Web Server after Server restart (several hours), you need to re-host or create new site in IIS Manager Pool.
I tried to reproduce the same in my environment and I got the results like below:
I have created sample website and when I tried Stop and Start action, localhost reached successfully:
As suggested by samwu you can check event viewer like below:
In start -> select event viewer -> click Windows Logs node
Select application Event Log and Search for errors associated with the failing app like below
You can make use of Debug Diagnostics tool.

Why are my Azure deployments to local IIS failing?

I'm deploying an asp.net core web app to local IIS 8.5 with an Azure pipeline. Deployments are failing because the .dll of the site is locked by IIS. This is despite the fact that I explicitly stop the site, using a IIS Web App Manage task, before the deployment.
The specific error is...
ERROR_FILE_IN_USE Web Deploy cannot modify the file'MyApp.dll' on the destination because it is locked by an external process
Why is this. What do I have to do to get IIS to release the .dll and let my pipeline do its thing?
Update
I've tried a powershell script to create a App_offline.htm file. The file's created, but the following Web App Deploy task still fails with the same error.
Ok fixed it. I needed to stop the app pool in addition to the website. So in the IIS web app manage task, in Additional appcmd.exe commands, put
stop apppool /apppool.name:"MyAppPool"

How to publish IIS Application from VisualStudio?

I'm looking to publish automatically by using Publish in VisualStudio my C# Application, so it's not a WebSite but it's a IIS Website application.
When using Publish profile and Publish to publish a website all works fine, but i can't get on how i can setup the Web Deploy to deploy a WebSite Application...
As by right clicking the application i have only import/export under Deploy while only the Website has "Configure Web Deploy Publishing" ...
Web Deploy simplifies deployment of Web applications and Web sites to IIS servers, and must be installed as an application on the server. you can refer to this link about how to configure the required settings for Web Deploy. Publish to a Web site

How do I mount an already existing php app to an empty azure php web app

Ok so I created an empty php web app in Azure, and I already have an existing php app that I have only tested locally, question is: How do I "transfer" that app to that empty php web app I created in Azure?
To migrate your existing PHP app to Azure Web Apps, you might need to do the following things:
Deploy all files of your PHP app to a virtual directory's root (D:\home\site\wwwroot) using FTP or source control:
Deploy your app to Azure App Service using FTP/S
Local Git Deployment to Azure App Service
Configure PHP in Azure App Service Web Apps
Azure Web Apps run on Microsoft IIS. If you have ever had your project run on Apache Web server, you also need to translate .htaccess ontent to IIS web.config.

MSDeploy when IIS application pool is down

If I shut down the application pool of the site in IIS 7.5 first, can I still use MSDeploy to deploy web code to this site?
The basic command is to execute C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe -source:package='......zip' -dest:auto,includeAcls='False' locally on the web server.
Yes, you can still deploy a site with MSDeploy if the AppPool is stopped.

Resources