Cannot publish to Azure Functions from Visual Studio 2019 - visual-studio

Previously I was able to publish to Azure Functions from Visual Studio but recently I always get an error saying that publish encountered an error. It directs to a log file the contents of which is as follows:
System.AggregateException: One or more errors occurred. ---> System.Exception: Publishing failed.
--- 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.Publish.Framework.Model.DefaultPublishSteps.<>c__DisplayClass26_0.<IsBuildCompletedSuccessfully>b__2()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- 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 Microsoft.Publish.Framework.Model.DefaultPublishSteps.<DefaultCorePublishStep>d__23.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 Microsoft.Publish.Framework.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__205.MoveNext()
(Inner Exception #0) System.Exception: Publishing failed.
System.Exception: Publishing failed.
I have tried the following:
Reset publish profile in Azure, create a new profile in Visual Studio and try publish again. Still same error.
Delete Function App in Azure and recreate it. Get new publish profile into Visual Studio and try publish again. Still same error.
Upgrade Visual Studio 2019 to latest Version (16.2.5) and try publish again. Still same error.
Note that I have a Azure website in the same solution and I can still publish that to Azure.

I am very new to Azure functions but today I had a similar problem (maybe the same problem) and I found a workaround, so I hope it will work also for you.
Visual studio publishes the function by sending (upload) a zip file to azure. Unfortunately it seems VS sets a timeout to send this file, so if it is too big or your connection is too slow in upload the publishing fails because it doesn't finish before the timeout :(
There are other ways to send the zip without VS, if you want to learn details see the link below, otherwise TL;DR just follow my simple instructions already tested below the link
https://learn.microsoft.com/en-us/azure/azure-functions/deployment-zip-push
I used the curl command and it works for me, no timeout. You can try also powershell or AZ cli but curl is really easy, just be careful to get right uid/pwd the uid in my case was "$"+"project_name"
here is an example, replace params with yours
curl -X POST -u your_username:your_password --data-binary #"your_zip_path" https://your_project_name.scm.azurewebsites.net/api/zipdeploy
Be patient and wait till the end the upload, there is no progress bar, see network activity, if it's sending data the upload is in progress. You find all the params inside the publishing file you can download from azure, they are also in VS. For the zip file you can use the one VS wasn't unable to deploy, Vs does not remove it, in my case it was under the proj dir in obj\Release\netcoreapp2.1\PubTmp
P.S I have WEBSITE_RUN_FROM_PACKAGE set to 1 this setting is recommended to 1 by many ms doc, so be careful changing to 0, you might have side effects.

If WEBSITE_RUN_FROM_PACKAGE is set as 1 it could cause issue with depoyment from visual studio:
Open the Azure portal and check if this is the case, if yes then set it as 0. It should work.
Here is the supporting link
Hope it helps, if not please share the code base will try to repro at my end.

For me it was failing to deploy to V3, but worked for V2

Related

Error 503 Service Unavailable when using localhost with Visual Studio

I'm posting this to save others a day wasting time trying to solve this.
My PC froze during a build and publish of my web application, so I had to switch the machine off and back on again. This coincided with a Windows Update being applied when the machine restarted.
After this I could not run the web application in Visual Studio, getting a Error 503 Service unavailable.
After trying everything mentioned here and elsewhere on the web, I noticed an app_offline.html file sitting in the solution folder. The file was empty.
I deleted the file and of course it all starts working. This file had been left during the incomplete build process.
So, hope this helps someone else.
Delete the app_offline.html file if one has been left after a broken build and publish process.
If you have IIS. Then go to IIS and click Application Pool, then click on default application pool and the clik on START.

Error Refreshing List in Rally Connector for Visual Studio

I am trying to use the Rally Connector for Visual Studio (with Visual Studio 2010 Pro SP1) and getting the following error when the connector tries to refresh the list 1) after successfully logging in or 2) when clicking Refresh List:
Unable to load data for Iterations filter drop-down due to a recent error. Please click "Refresh List" to reload list.
Again, clicking Refresh List simply yields the same error.
I am using version 1.6.5 of the connector.
I will pursue support from Rally if necessary once I get a chance; in the meantime, searching the Rally Knowledge Base didn't seem to yield anything related to the error; a web search turned up nothing useful; and I have replied to a related question (regarding the error with an earlier version(s) of the connector) in the Visual Studio Gallery page linked above. Basically I am trying to work this from all reasonable angles.
Here is what I see in the connector activity log (with the workspace value replaced in logged URLs for obvious reasons):
4/24/2013 8:23:35 PM Sent request to load Tasks
4/24/2013 8:23:36 PM Got response to load Tasks
4/24/2013 8:23:36 PM Sent request to get all iterations in workspace https://rally1.rallydev.com/slm/webservice/1.15/workspace/9876543210
4/24/2013 8:23:36 PM Got response to get all iterations in workspace https://rally1.rallydev.com/slm/webservice/1.15/workspace/9876543210
4/24/2013 8:23:37 PM Warning: Following exception was thrown during getting distinct Iterations:
System.OverflowException: Value was either too large or too small for an Int32.
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at RallyConnector.RallyLoader.GetDistinctIterations(DataSet ds)
Code resumed with duplicate Iterations.
When I login to Rally through my browser, I do indeed see iterations with the same names; but those iterations are for different projects; and I certainly don't see an iteration count to overflow a 32-bit integer. I would expect that whatever has been entered into Rally through browsers would work just fine with the connector.
Can duplicate iteration names really be the problem, or is something else at play? Has anyone encountered and managed to resolve this error?
Sorry for the difficulty.
This error “Unable to load data for Iterations filter drop-down due to a recent error. Please click Refresh List to reload list”. And usually the "Refresh List" action will not fix the issue. This is a known issue which should be resolved for version >= 1.6.4 of the plugin. If you were running a previous version of the add-in you may need to do a clean reinstall (after uninstalling your present instance) in order to overcome this error.
A clean reinstall is the key - in my experience clean reinstall of the version 1.6.4 or higher always fixed this problem.
Before you re-install , please follow these steps to uninstall your current instance:
Close Visual Studio
Uninstall the current Visual Studio plugin
(Control Panel >> Add-Remove Programs)
In a Windows Explorer window,
navigate to (example from Windows 7):
"C:\Users\username\Documents\" (or the equivalent folder for your
version of Windows)
Delete the folder named "RallyPlugin" from the "Documents" folder.
Please followup if this fails to resolve the issue.

TF30170 : Can't create new Team Projects anymore

We used to have a great time with our TFS 2010 installation, but all of a sudden it seems to stab us in the back.
When we try to create a new Team Project (either via VS2010 or VS2012 Team Explorer), TFS encounters an error when importing the Process Templates. It doesn't matter which of the installed Templates i select, the error is always the same.
2013-01-16T11:11:08 | Modul: Work Item Tracking | Thread: 39 | Uploading task type from file "C:\Users\user1\AppData\Local\Temp\TPW_tmp447E.tmp\WorkItem Tracking\TypeDefinitions\Bug.xml" hochgeladen...
---Begin Exception---
Zeit: 2013-01-16T11:11:08
Modul: Engine
Exception Description: TF30162: Error at Task "WITs" from Group "WorkItemTracking".
Exception Type: Microsoft.TeamFoundation.Client.PcwException
Exception Message: TF24016: Team project "MyInfoservice" not found.
Stacktrace:
at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.Execute(ProjectCreationContext ctxt, XmlNode taskXml)
at Microsoft.VisualStudio.TeamFoundation.ProjectCreationEngine.TaskExecutor.PerformTask(IProjectComponentCreator componentCreator, ProjectCreationContext context, XmlNode taskXml)
bei Microsoft.VisualStudio.TeamFoundation.ProjectCreationEngine.RunTask(Object taskObj)
-- Inner Exception --
Ausnahmemeldung: TF24016: Team project "MyInfoservice" not found. (Type WitPcwFatalException)
Ausnahmestapelüberwachung: at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.ContextWrapper.get_Project()
at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.WitPcwTask.WorkItemTypesTask.UploadTypeDefinition(String file, Boolean execute)
at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.WitPcwTask.WorkItemTypesTask.Execute()
at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.Parse(ContextWrapper wrapper, XmlNode taskXml, Boolean fExecute)
at Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.WitPcwPlugin.PcwPluginComponentCreator.Execute(ProjectCreationContext ctxt, XmlNode taskXml)
---End Exception---
EDIT : My colleague just found out that this doesn't occur on any other machines, so it must be our Visual Studio instances that are messed up.
So why are they messed up? We caused a desaster by making attempts at desaster recovery (What happens if we have just the database dump of our TFS Collection?). What we've done, in short:
Make a backup of TFS Database (without detaching it from the TFS)
Create a second Server and reattach the database there
Run TfsConfig Recover on the DataBase
At first sight, the result seemed to be OK, but at a closer look, many problems surfaced. I guess they go back to the fact that visual studio connected to two servers with the same project- and collection GUIDs, but that's just a guess. Now we're trying to get our machines back to work the way they did when only one TFS was being connected to.
Tried but not working:
devenv resetsettings
deleting all VisualStudio and TeamFoundation folders below C:\users\user1\AppData\Local and Roaming
deleting registry keys that contain the TFS server names
Can anyone point me in the right direction what else we can try?
After a few more or less desperate attempts I was finally able to solve this.
Since the exception occured when a file from my local Temp folder was uploaded to TFS, I tried clearing the entire TEMP folder. That did the trick. The relevant information is the first line of the log output I posted above.
Uploading task type from file "C:\Users\user1\AppData\Local\Temp\TPW_tmp447E.tmp\WorkItemTracking\TypeDefinitions\Bug.xml"
I had a similar problem after restoring a TFS 2012 Express collection from backup. I resolved it by deleting the TFS cache on the local dev. machine. I just removed the entire Cache folder...
C:\Users\myUsername\AppData\Local\Microsoft\Team Foundation\5.0\Cache
If you have another dev. machine handy then you can check if you can create a TFS project on it. If you can then the problem is with your dev. machine, most likely the cache.

Configuring ObjectDataSource: Exception has been thrown by the target of an invocation

In my project in Visual Studio 2010, I'm trying to add an Object Data Source which points to one to my business services, and to bind the datasource to a datagrid (or datalist, or whatever).
The problem is, after adding the ObjectDataSource from the toolbox, when I hit the "Configure Data Source" link to open the configuration wizard I get this error:
Error invoking Configure Data Source - Exception has been thrown by
the target of an invocation
This only happens in my project (i.e. if I create a blank project, ObjectDataSource configuration works properly).
Searching similar questions here in stackoverflow and on the internet I've read that this error is often related to a missing assembly. In fact, my project references several .dlls, and after checking time and again I just can't see what is missing. I also tried enhabling logging on Visual Studio, but it doesn't log anithing related to that error.
So: is there a way to get a more exhaustive error message from Visual Studio? Perhaps accessing the "inner exception" that fired the error, like you do when debugging your code?
And by the way: is there a way to configure "manually" ObjectDataSources without using the wizard?

Publish Wizard Errors in VS2010 and 2012

I've been using the Publish Wizard in VS2010 to deploy my MVC app and I've got no issues there but intermittently the publish will fail with the following error.
Error 23 Web deployment task failed.(Could not complete the request to
remote agent URL 'https://webserver:8172/msdeploy.axd?site=mysite'.)
Could not complete the request to remote agent URL
'https://webserver:8172/msdeploy.axd?site=mysite'. The request was
aborted: The request was canceled. COM object that has been separated
from its underlying RCW cannot be used.
It seems to happen at random but the longer I have VS open the more likely it is to occur and the guaranteed way to fix it is to restart VS but it occurs like clockwork if I leave VS open for prolonged periods of time (all day or overnight) and is starting to get very frustrating to have to restart VS every time it happens. I honestly don't recall if the error number is always 23 or not, I'll look for that next time it happens, but has anyone else had this problem or know what might be causing it?
Update:
The problem is still present when using VS2012 as well.
We discovered this bug shortly after finalizing the RTW components for web publishing. To give you a bit of background, the underlying issue was very difficult for us to uncover. After some through investigation we were able to pinpoint the issue to being related to how internet connections are managed by the singleton RCW object used by WPF and whether requests are coming in on an STA or MTA thread.
Fortunately we were able to workaround the underlying issue and have a fix ready. We are planning to update the web publishing bits in a few months which should resolve this issue once and for all. Until then the workaround is to close VS and then re-open it. I know that this is not an ideal workaround, but that is the best that we can do at this time.
According to http://www.asp.net/mvc/tutorials/deployment/deployment-to-a-hosting-provider/deployment-to-a-hosting-provider-creating-and-installing-deployment-packages-12-of-12
"COM object that has been separated from its underlying RCW cannot be
used." Scenario You have been successfully using one-click publish
to deploy your application and then you start getting this error:
Web deployment task failed. (Could not complete the request to remote
agent URL 'https://serverurl.com/msdeploy.axd?site=sitename'.) Could
not complete the request to remote agent URL
'https://url/msdeploy.axd?site=sitename'. The request was aborted: The
request was canceled. COM object that has been separated from its
underlying RCW cannot be used.
the solution is:
Possible Cause and Solution
Closing and restarting Visual Studio is usually all that is required to resolve this error.

Resources