简体   繁体   中英

How to fix error publishing to azure function

I have a functionapp that I made in visual studio 2019. I want to publish this app to an azure function that already exists in Azure. But when I try to publish from VS I get the following error:

在此处输入图像描述

I tried to update VS to the latest version and updating the Microsoft.NET.Sdk.Functions packet to version 1.0.35 since the following versions require.NetCore 3 and I use.NetCore 2.1. I also tried to do a Webdeploy but got the same error.

When I changed my.NetCore version to 3.1 and do a WebDeploy I now get this error: 在此处输入图像描述

I looked this up and people said to change the WEBSITE_RUN_FROM_PACKAGE value to 0, I tried this and even tried deleting this and it still gave the same error.

I also tried ZIP-deploy and then I get this error: 在此处输入图像描述

I also edited the runtimesettings when I changed the version.

My project structure: 在此处输入图像描述

In the map IntentFunctions are 6 other azure functions.

Even creating a new app service from VS and then publishing doesn't work.

I saw that most other azure function apps have a json file for each function and I do not have this only a host.json file, might this be the problem?

Anyone know a fix? Thanks in advance

It seems like Azure Functions default to use.Net Core 3. If you want to change the version, according to this link: https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions , you should be able to change the FUNCTIONS_EXTENSION_VERSION application setting to ~2. Also you can set the AzureFunctionsVersion in your.csproj like so: <AzureFunctionsVersion> v2 </AzureFunctionsVersion>

I do not think your problem is the version of the Function. Framework version would be the problem if the application was deployed successfully but could not start. Your problem is that the ZIP package can not make it to the server, according to the logs.

I had a similar problem before when deploying from VS from home, the problem was slow home internet connection.

Here is the link that helped me: Publish to Azur fails with 500 internal Server Error

Updated Answer

I generally distrust visual studio because it is doing a lot of stuff under the hoods and caches a lot of data to boost performance. You can instead try to use another mean of publishing as explained by Microsoft here https://docs.microsoft.com/en-us/azure/azure-functions/deployment-zip-push , like a rest call or azure cli.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM