projectkudu / kudu

Kudu is the engine behind git/hg deployments, WebJobs, and various other features in Azure Web Sites. It can also run outside of Azure.
Apache License 2.0
3.12k stars 652 forks source link

Unable to update/install application insights site extension #2606

Closed xt0rted closed 6 years ago

xt0rted commented 7 years ago

One of my sites indicated that there was a new version of the app insights extension available so I tried to update it. Upon clicking update I received an error saying a file was in use and it couldn't update and then the extension disappeared from the list of installed extensions. Now each time I try to reinstall the extension I get the following error.

Failed to install Application Insights - System.IO.DirectoryNotFoundException:
 Could not find a part of the path 'D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\Runtime'.
  at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
  at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
  at System.IO.Abstractions.DirectoryWrapper.Delete(String path, Boolean recursive)
  at Kudu.Core.Infrastructure.FileSystemHelpers.MoveDirectory(String sourceDirName, String destDirName)
  at Kudu.Core.SiteExtensions.SiteExtensionManager.<>c__DisplayClass27_1.b__1()
  at Kudu.Core.Infrastructure.OperationManager.<>c__DisplayClass2_0.b__0()
  at Kudu.Core.Infrastructure.OperationManager.Attempt[T](Func`1 action, Int32 retries, Int32 delayBeforeRetry, Func`2 shouldRetry)
  at Kudu.Core.Infrastructure.OperationManager.Attempt(Action action, Int32 retries, Int32 delayBeforeRetry)
  at Kudu.Core.SiteExtensions.SiteExtensionManager.EnsureInstallationEnviroment(String installationDir, ITracer tracer)
  at Kudu.Core.SiteExtensions.SiteExtensionManager.d__26.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Kudu.Core.SiteExtensions.SiteExtensionManager.d__25.MoveNext()

I tried to update the extension through the SCM site, not the portal.

davidebbo commented 7 years ago

Does it help if you stop the site first? Also, you can try manually deleting the D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites folder from Kudu Console. And if that fails, it would be interesting to use Kudu Process Explorer to check what might have a handle locking it,

/cc @iusafaro

xt0rted commented 7 years ago

I checked D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites and there was a SiteExtensionStatus.json in it with the same error I first reported. I then restarted the site and tried installing again. This time it installed ok.

Once the extension was installed I couldn't browse to xxxxx.scm.azurewebsites.net/ApplicationInsights/ without first restarting the SCM site.

Everything seems to be working now.

davidebbo commented 7 years ago

Once the extension was installed I couldn't browse to xxxxx.scm.azurewebsites.net/ApplicationInsights/ without first restarting the SCM site.

This part is normal, as the application.xdt needs a restart to take effect.

xt0rted commented 7 years ago

I just ran into this issue on another site. The first error after clicking update is

Failed to update Application Insights - System.IO.IOException:
 The process cannot access the file 'D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\Instrumentation32\ProductionBreakpoints_x86.dll' because it is being used by another process.
 at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
 at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
 at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
 at System.IO.Abstractions.FileWrapper.OpenWrite(String path)
 at Kudu.Core.SiteExtensions.FeedExtensions.d__5.MoveNext()
 --- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 t Kudu.Core.SiteExtensions.SiteExtensionManager.d__27.MoveNext()
 --- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
 at Kudu.Core.SiteExtensions.SiteExtensionManager.d__26.MoveNext()

Once the site is restarted the app insights extension can be reinstalled.

xt0rted commented 7 years ago

I went through and updated the rest of my sites, they all produced the same error and needed to be restarted and the extension reinstalled.

xt0rted commented 6 years ago

This looks to have been resolved with https://github.com/projectkudu/kudu/pull/2621. I haven't had an issue updating any of my AI site extensions in recent months.