Kudu: InvalidOperationException when attempting Zip Push Deploy

Created on 25 Apr 2018  路  8Comments  路  Source: projectkudu/kudu

Does someone have an idea what is going wrong here? The error message is not very specific.

Repro steps.

Deploy a Web App to App Service using the Zip Deploy HTTP API (documented here: https://github.com/projectkudu/kudu/wiki/Deploying-from-a-zip-file).

Project structures.

The app is an ASP.NET Core app; the zip file contains the output of dotnet publish. I can give the exact zip file if necessary.

The log/error given by the failure.

I get an HTTP status code 500 and some json describing a .NET exception. The same information is included below (copied from a trace xml-file on the web server). The existing deployment appears untouched and the app remains running.

<step title="Error occurred" date="2018-04-25T09:53:59.663" type="error" text="Operation is not valid due to the current state of the object." stackTrace="   at Kudu.Core.SourceControl.NullRepository.GetChangeSet(String id) in C:\Kudu Files\Private\src\master\Kudu.Core\SourceControl\NullRepository.cs:line 70
   at Kudu.Core.Deployment.FetchDeploymentManager.&lt;PerformDeployment&gt;d__9.MoveNext() in C:\Kudu Files\Private\src\master\Kudu.Core\Deployment\FetchDeploymentManager.cs:line 235
--- 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 Kudu.Core.Deployment.FetchDeploymentManager.&lt;&gt;c__DisplayClass8_0.&lt;&lt;FetchDeploy&gt;b__0&gt;d.MoveNext() in C:\Kudu Files\Private\src\master\Kudu.Core\Deployment\FetchDeploymentManager.cs:line 115
--- 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 Kudu.Contracts.Infrastructure.LockExtensions.&lt;LockOperationAsync&gt;d__5`1.MoveNext() in C:\Kudu Files\Private\src\master\Kudu.Contracts\Infrastructure\LockExtensions.cs:line 100
--- 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 Kudu.Core.Deployment.FetchDeploymentManager.&lt;FetchDeploy&gt;d__8.MoveNext() in C:\Kudu Files\Private\src\master\Kudu.Core\Deployment\FetchDeploymentManager.cs:line 108
--- 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 Kudu.Services.Deployment.PushDeploymentController.&lt;PushDeployAsync&gt;d__10.MoveNext() in C:\Kudu Files\Private\src\master\Kudu.Services\Deployment\PushDeploymentController.cs:line 147
--- 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 Kudu.Services.Deployment.PushDeploymentController.&lt;ZipPushDeploy&gt;d__8.MoveNext() in C:\Kudu Files\Private\src\master\Kudu.Services\Deployment\PushDeploymentController.cs:line 80
--- 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.Threading.Tasks.TaskHelpersExtensions.&lt;CastToObject&gt;d__3`1.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.Web.Http.Controllers.ApiControllerActionInvoker.&lt;InvokeActionAsyncCore&gt;d__0.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.Web.Http.Filters.ActionFilterAttribute.&lt;CallOnActionExecutedAsync&gt;d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Web.Http.Filters.ActionFilterAttribute.&lt;CallOnActionExecutedAsync&gt;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)
   at System.Web.Http.Filters.ActionFilterAttribute.&lt;ExecuteActionFilterAsyncCore&gt;d__0.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.Web.Http.Filters.ActionFilterAttribute.&lt;CallOnActionExecutedAsync&gt;d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Web.Http.Filters.ActionFilterAttribute.&lt;CallOnActionExecutedAsync&gt;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)
   at System.Web.Http.Filters.ActionFilterAttribute.&lt;ExecuteActionFilterAsyncCore&gt;d__0.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.Web.Http.Controllers.ActionFilterResult.&lt;ExecuteAsync&gt;d__2.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.Web.Http.Controllers.ExceptionFilterResult.&lt;ExecuteAsync&gt;d__0.MoveNext()" />

Debug your Azure website remotely.

The name of the web app is progresselections.

Mention any other details that might be useful.

The app was previously deployed using webdeploy (from Visual Studio). The deploy is initiated by AppVeyor (as documented here: https://www.appveyor.com/docs/deployment/azure-app-service-zip-push-deploy/).

Most helpful comment

Ok, I understand the problem now. If you look at your D:\home\site\deployments\settings.xml, it has:

    <deployment>
        <add key="branch" value="productie" />
    </deployment>

This is likely some remnant of some previous deployment flow that you were using, and it is confusing zipdeploy. Just yank the add tag and you'll be ok.

@suwatch, it's probably a general issue with all scenarios that use NullRepository. The code expects the branch to be 'master' and it doesn't play well when a different branch is set in settings.xml.

But at least it's easy to workaround.

All 8 comments

Have not seen this one before. A few things to test to help isolate:

  1. if you create a brand new test app, and do the zipdeploy as the first action, do you see this?
  2. What if you use a trivial zip that just contains an index.html at the root any nothing else?
  3. If you go to Kudu and go under Tools / Zip Push Deploy, it gives you a UI where you can drag and drop a zip, which does a zip deploy. Does it repro there as well?
  1. I created a new WebApp in the same App Service plan and the deployed the zip there using the drag and drop method and it worked fine.
  2. Gives the same error (but wrapped in AggregateException, working from the Kudu dashboard here).
  3. Gives the same error (but wrapped in AggregateException).

Ok, I understand the problem now. If you look at your D:\home\site\deployments\settings.xml, it has:

    <deployment>
        <add key="branch" value="productie" />
    </deployment>

This is likely some remnant of some previous deployment flow that you were using, and it is confusing zipdeploy. Just yank the add tag and you'll be ok.

@suwatch, it's probably a general issue with all scenarios that use NullRepository. The code expects the branch to be 'master' and it doesn't play well when a different branch is set in settings.xml.

But at least it's easy to workaround.

Should the NullRepository be independent of or simply ignore branch settings?

@davidebbo Thanks for the clarification. I did indeed try to set up continuous deployment from GitHub earlier, using that exact branch.

@suwatch it probably should ignore it, but I don't know the history behind that logic.

Another angle is that if you have a GitHub (or whatever) CI set up, and then you disconnect it, we should be cleaning up the branch as part of that, which would have avoided this issue.

But let's keep in perspective: this is a rare situation with an easy workaround. So I don't think this is high priority given everything else we have going.

zipdeploy is working as expected now.

thanks @davidebbo the same thing happened to me, modify the settings file pointing to the correct repository and it works correctly,

Was this page helpful?
0 / 5 - 0 ratings