Cannot Publish Azure Function from Visual Studio 2022

Mindy 11 Reputation points
2022-01-10T17:13:41.907+00:00

When I try to publish an Azure function from Visual Studio 2022, I get the following error.

------ Publish started: Project: FunctionTest, Configuration: Release Any CPU ------
Publishing C:\Users\me\source\FunctionTest\obj\Release\net6.0\PubTmp\FunctionTest - 20220110084404804.zip to https://functionnamehere.scm.azurewebsites.net/api/zipdeploy...
The "ZipDeployTask" task failed unexpectedly.
System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: Error while copying content to a stream. ---> System.IO.IOException: Unable to read data from the transport connection: The connection was closed.
   at System.Net.ConnectStream.EndWrite(IAsyncResult asyncResult)
   at System.Net.Http.StreamToStreamCopy.BufferWrittenCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.NET.Sdk.Functions.Http.HttpClientHelpers.<PostWithBasicAuthAsync>d__0.MoveNext() in /_/src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/Http/HttpClientHelpers.cs:line 36
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.NET.Sdk.Functions.Tasks.ZipDeployTask.<ZipDeployAsync>d__26.MoveNext() in /_/src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/ZipDeployTask.cs:line 90
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Microsoft.NET.Sdk.Functions.Tasks.ZipDeployTask.Execute() in /_/src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/ZipDeployTask.cs:line 42
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
---> (Inner Exception #0) System.Net.Http.HttpRequestException: Error while copying content to a stream. ---> System.IO.IOException: Unable to read data from the transport connection: The connection was closed.
   at System.Net.ConnectStream.EndWrite(IAsyncResult asyncResult)
   at System.Net.Http.StreamToStreamCopy.BufferWrittenCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.NET.Sdk.Functions.Http.HttpClientHelpers.<PostWithBasicAuthAsync>d__0.MoveNext() in /_/src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/Http/HttpClientHelpers.cs:line 36
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.NET.Sdk.Functions.Tasks.ZipDeployTask.<ZipDeployAsync>d__26.MoveNext() in /_/src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/ZipDeployTask.cs:line 90<---

If I try to publish using web deploy instead of zip deployment, it gets:

Retrying the sync because a socket error (10054) occurred.

It can send some of the files with web deploy but cannot make it through all of the files within the 50 attempts. I have disabled all firewalls. I tried to use a VPN. I tried different computers. It works perfectly most days but some days/times I have problems for hours. Any suggestions?

Thanks!

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,301 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Mindy 11 Reputation points
    2022-01-10T18:17:10.957+00:00

    After further testing, this appears to be a network issue.

    1 person found this answer helpful.

  2. Mindy 11 Reputation points
    2022-01-11T08:18:13.95+00:00

    @Mike Urnun Yes Mike, the problem was related to signals between the modem and ISP. This caused significant packet loss. Resolving the connection issue resolved the problem. Thanks!

    1 person found this answer helpful.