Azure / Azure-Functions

1.12k stars 198 forks source link

Initial Publish Failed from Visual Studios 2017 #506

Open jake82w opened 7 years ago

jake82w commented 7 years ago

I created a new function app in Visual Studio 2017. Then published the app by right clicking the project and selecting publish. I created a new function app to publish. After filling out the required info and clicking publish I get a pop-up dialog box saying the publish failed. If I log into the portal I see the new function app. If I publish again from VS 2017 it completes successfully. I was able to reproduce this on 3 separate projects.

Function Names: WTrackerApp, WTFuncApp, WTFuncApp2

VS Console output:

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
  Publish Started
  WTFuncApp -> E:\Git\WTFuncApp\WTFuncApp\bin\Release\net461\bin\WTFuncApp.dll
  WTFuncApp -> E:\Git\WTFuncApp\WTFuncApp\obj\Release\net461\PubTmp\Out\
C:\Program Files\dotnet\sdk\2.0.0\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(138,5): error : Web deployment task failed. (Could not connect to the remote computer ("wtrackerapp.scm.azurewebsites.net") using the specified process ("Web Management Service") because the server did not respond. Make sure that the process ("Web Management Service") is started on the remote computer.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC.) [E:\Git\WTFuncApp\WTFuncApp\WTFuncApp.csproj]
C:\Program Files\dotnet\sdk\2.0.0\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(138,5): error :  [E:\Git\WTFuncApp\WTFuncApp\WTFuncApp.csproj]
C:\Program Files\dotnet\sdk\2.0.0\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(138,5): error : Could not connect to the remote computer ("wtrackerapp.scm.azurewebsites.net") using the specified process ("Web Management Service") because the server did not respond. Make sure that the process ("Web Management Service") is started on the remote computer.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC. [E:\Git\WTFuncApp\WTFuncApp\WTFuncApp.csproj]
C:\Program Files\dotnet\sdk\2.0.0\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(138,5): error : The remote server returned an error: (503) Server Unavailable. [E:\Git\WTFuncApp\WTFuncApp\WTFuncApp.csproj]
  Publish failed to deploy.

VS info:

Microsoft Visual Studio Enterprise 2017 Version 15.3.5 VisualStudio.15.Release/15.3.5+26730.16 Microsoft .NET Framework Version 4.7.02053

Installed Version: Enterprise

Visual Basic 2017 00369-60000-00001-AA517 Microsoft Visual Basic 2017

Visual C# 2017 00369-60000-00001-AA517 Microsoft Visual C# 2017

Visual F# 4.1 00369-60000-00001-AA517 Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package 8.8.00712.1 Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017 15.0.30726.0 ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services 1.0 Provides languages services for ASP.NET Core Razor.

ASP.NET Template Engine 2017 15.0.30726.0 ASP.NET Template Engine 2017

ASP.NET Web Frameworks and Tools 2017 5.2.50601.0 For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 15.0.30728.0 Azure App Service Tools v3.0.0

Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio 2.2.9000.1 Microsoft Azure Data Lake Tools for Visual Studio

Azure Data Lake Tools for Visual Studio 2.2.9000.1 Microsoft Azure Data Lake Tools for Visual Studio

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events

JavaScript Language Service 2.0 JavaScript Language Service

JavaScript Project System 2.0 JavaScript Project System

JavaScript UWP Project System 2.0 JavaScript UWP Project System

Merq 1.1.17-rc (cba4571) Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure HDInsight Azure Node 2.2.9000.1 HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service 2.2.9000.1 Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio 1.7 Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service 2.2.9000.1 Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50719.1

Microsoft Continuous Delivery Tools for Visual Studio 0.3 Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio 4.6.8-pre (ec7034f) Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 4.3.1 NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

SQL Server Data Tools 15.1.61707.200 Microsoft SQL Server Data Tools

ToolWindowHostedEditor 1.0 Hosting json editor into a tool window

TypeScript 2.3.4.0 TypeScript tools for Visual Studio

Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Universal Windows Apps 15.0.26730.08 The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

WebJobs Tools v1.0.0 15.0.30901.0 WebJobs Tools v1.0.0

Xamarin 4.7.9.45 (bd7e3753c) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK 7.4.5.1 (fb018c5) Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK 11.0.0.0 (152b654) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

JohnReeson commented 6 years ago

I can reproduce this error, but I have no idea the cause and how to reproduce it exactly. During my test, it happened several times when publishing immediately function v2 template created on consumption plan. However, it also succeeded once. Any suggestions?

paulbatum commented 6 years ago

@vijayrkn FYI

PrimeHydra commented 6 years ago

I get this as well, publishing v2 function when I am creating new API plan, function app, and storage account (consumption). I click "Create" in the dialog, and after a moment I get "publish failed".

After that, I just hit the Publish button in Publish pane, and it goes through. Some kind of timeout related to waiting on the new resources?

FWIW this also happened when publishing a v1 function.

dluc commented 6 years ago

Similar issue here with v2. The initial deployment goes through, then VS keeps failing with "Publishing failed". No logs to debug.

Any news?

paulbatum commented 6 years ago

I suspect you're running into https://github.com/Azure/azure-functions-host/issues/2700

This is a general problem with .NET core apps, discussed here: https://github.com/aspnet/IISIntegration/issues/226

We have some work in progress around supporting app_offline, and we are optimistic that this will address: https://github.com/Azure/azure-functions-host/pull/3196

My guess is that this should be rolled out sometime in August.

DanRigby commented 6 years ago

Experienced this today when migrating a Functions v1 app to v2 and doing the initial deploy from VS. Going into the Azure Portal, stopping the Function app, and then deploying did cause it to succeed.

The error messages provided in the output, "Could not connect to the remote computer, The remote server returned an error: (503) Server Unavailable.", unfortunately don't provide any insight into the cause of the issue or potential resolutions. Is this something we can fix in the short term?

paulbatum commented 6 years ago

So perhaps there are multiple issues here. In my reply above, I was referring to publishing failures that have a failure relating to locked files that look like this:

  Publish Started
  IrisPredictorLibrary -> D:\code\temp\MLFunctionsTest\IrisPredictorLibrary\bin\x64\Debug\netstandard2.0\IrisPredictorLibrary.dll
  IrisFunctionApp -> D:\code\temp\MLFunctionsTest\IrisFunctionApp\bin\x64\Debug\netstandard2.0\bin\IrisFunctionApp.dll
  IrisFunctionApp -> D:\code\temp\MLFunctionsTest\IrisFunctionApp\obj\Debug\netstandard2.0\PubTmp\Out\
  Updating file (pbfunctions-iristest\bin\IrisFunctionApp.dll).
C:\Program Files\dotnet\sdk\2.1.302\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error : Web deployment task failed. (Web Deploy cannot modify the file 'IrisFunctionApp.dll' on the destination because it is locked by an external process.  In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.) [D:\code\temp\MLFunctionsTest\IrisFunctionApp\IrisFunctionApp.csproj]
  Publish failed to deploy.

But @DanRigby and others have shared failures that instead have a 503 error. I'm not sure what to make of that yet. Does anyone have reliable repro steps?

paulbatum commented 6 years ago

Alternatively, if anyone can share with me their function app name and a utc timestamp for when they got the error Could not connect to the remote computer, The remote server returned an error: (503) Server Unavailable, that would help.

DanRigby commented 6 years ago

I just created another two new Function Apps, did the initial deploy, and did not receive a deployment error either time.

@paulbatum The function app name that I got the deployment error on was https://linkfunctions.azurewebsites.net, but I don't have an exact timestamp for you, only that it would have occurred between 5:00 - 5:20pm UTC today, August 2nd.

chavansachin20 commented 6 years ago

This error pops up when you use esising project and try to publish it from another machine.

Resolution :

  1. Go into the Azure Portal -> Function Apps -> Select your Function
  2. Click on Reset publish credentials image
  3. Try to publish now from VS 2017.

If again it still doesn't work : follow below steps from VS 2017

  1. Go to VS 2017
  2. right click on solution image
  3. Click on publish
  4. Delete profile
  5. click on Start image
  6. select existing app service image
  7. click on Create profile image
  8. select you Subscription & view and App Service > Click on OK
  9. you profile is created
  10. no click on Publish image

you should able to publish your project.

please reply with your comments.

Thanks Sachin Chavan

riserrad commented 5 years ago

So perhaps there are multiple issues here. In my reply above, I was referring to publishing failures that have a failure relating to locked files that look like this:

  Publish Started
  IrisPredictorLibrary -> D:\code\temp\MLFunctionsTest\IrisPredictorLibrary\bin\x64\Debug\netstandard2.0\IrisPredictorLibrary.dll
  IrisFunctionApp -> D:\code\temp\MLFunctionsTest\IrisFunctionApp\bin\x64\Debug\netstandard2.0\bin\IrisFunctionApp.dll
  IrisFunctionApp -> D:\code\temp\MLFunctionsTest\IrisFunctionApp\obj\Debug\netstandard2.0\PubTmp\Out\
  Updating file (pbfunctions-iristest\bin\IrisFunctionApp.dll).
C:\Program Files\dotnet\sdk\2.1.302\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(139,5): error : Web deployment task failed. (Web Deploy cannot modify the file 'IrisFunctionApp.dll' on the destination because it is locked by an external process.  In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.) [D:\code\temp\MLFunctionsTest\IrisFunctionApp\IrisFunctionApp.csproj]
  Publish failed to deploy.

But @DanRigby and others have shared failures that instead have a 503 error. I'm not sure what to make of that yet. Does anyone have reliable repro steps?

I'm having the same problem. I need to restart my function to make the deploy work. I still have no idea why the process is keeping the DLL Handle.

ColbyTresness commented 5 years ago

This issue was moved to Azure/azure-functions-vs-build-sdk#294

ColbyTresness commented 5 years ago

Reverting move, tracking here.

ColbyTresness commented 5 years ago

@soninaren to take a look

ColbyTresness commented 5 years ago

@soninaren ping

soninaren commented 5 years ago

From the comments above i can think of a few things leading to individual causes.

  1. For initial deployment failure after creating a new function app.

    • This could be a timing issue and we may be deploying before all the resources have been fully provisioned. There may be a status endpoint in arm that we could leverage to make sure we perform deployment when the app is ready for deployment. We could also use the same endpoint to provide a better error message.
  2. Deployment failure because of the dll locking.

    • This could be resolved in 2 ways. Either use Run from Package file at the time of publishing or make sure you have <EnableMsDeployAppOffline>True</EnableMsDeployAppOffline> file in the .pubxml. This makes sure that the app is offline and dll's are unlocked before deployment starts.
  3. In reference to the folks to getting 503.

    • I think it could have caused because of back to back deployment. VS may have add/updated an app setting based on the selected configuration. This would cause the app to restart, The first deployment could have failed because of dll locking but VS would have updated the app setting here and caused the app to restart. The deployment following that would get 503 because of app being restarted.

Let me know if anyone is still experiencing any of the above mentioned issues. If so a repro or an app name and deployment time would help.