Unhandled Excepton updating multiple applicationPools
IIS.Administration does not handle multiple updates. Because IIS configuration is all saved to a file only 1 update at a time can open and edit the file.
2 API calls that changes that file causes an unhandled exception An unhandled exception has occurred while executing the request.
Exception: System.IO.FileLoadException: Filename: \?...\inetsrv\config\applicationHost.config Error: Cannot commit configuration changes because the file has changed on disk
at Microsoft.Web.Administration.Interop.IAppHostWritableAdminManager.CommitChanges() at Microsoft.Web.Administration.ConfigurationManager.CommitChanges() at Microsoft.Web.Administration.ServerManager.CommitChanges() at Microsoft.IIS.Administration.WebServer.MgmtUnit.Commit() at Microsoft.IIS.Administration.WebServer.AppPools.AppPoolsController.Patch(String id, Object model) at lambda_method115(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) at Microsoft.IIS.Administration.WebServer.Injector.ProceedNoTransaction(HttpContext context) at Microsoft.IIS.Administration.WebServer.Injector.Invoke(HttpContext context) at Microsoft.IIS.Administration.HeadTransform.Invoke(HttpContext context) at Microsoft.IIS.Administration.Startup.<>c.<<Configure>b__4_0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.Security.Authorization.AuthorizationPolicyMiddleware.Invoke(HttpContext context, IAuthorizationService authorizationService) at Microsoft.IIS.Administration.Cors.CorsExtensions.<>c.<<UseCrossOrigin>b__0_2>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.Cors.CorsExtensions.<>c__DisplayClass0_0.<<UseCrossOrigin>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.ErrorHandler.Invoke(HttpContext context) at Microsoft.IIS.Administration.ErrorHandler.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)