How to fix error publishing to azure function - c#

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

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://learn.microsoft.com/en-us/azure/azure-functions/deployment-zip-push , like a rest call or azure cli.

It seems like Azure Functions default to use .Net Core 3. If you want to change the version, according to this link: https://learn.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>

Related

ASP.NET Core app with Angular in Visual Studio - API does not run

I have been following this tutorial (Create an ASP.NET Core app with Angular in Visual Studio),
After following all the steps and running the solution at the end, it seems the Angular project is running successfully, however, the API doesn't run. I've tried hitting the API endpoint via postman and the breakpoints within Visual Studio are never hit.
From the angular app, within dev tools I see 504 Gateway Timeout when hitting https://localhost:4200/weatherforecast
Has anyone experienced this before? if so, how do you fix it?
I tired what is shown here, but the outcome is still the same.
Managed to resolve, seems I'm running the latest version of Nodejs which isn't support, ended up installing Node Version Manager and installing a version which was support, in my case v16.13.2
Once installed I then ran, nvm use 16.13.2, kicked off the project and voilĂ  it calls the backend api with no issues and displays the data :)
Hope it helps.

Is it literally impossible to build a SQL Server database project in Azure Data Studio on an M1 Mac?

I'm attempting to set myself up with Azure Data Studio on my new M1 Mac Mini, but the SQL Server database project I'm working on refuses to build. This is the (completely useless) error I'm getting:
stdout: /Users/dumasded/.azuredatastudio/extensions/microsoft.sql-database-projects-0.13.0/BuildDirectory/Microsoft.Data.Tools.Schema.SqlTasks.targets(586,5): error MSB4181: The "SqlBuildTask" task returned false but did not log an error. [/Users/dumasded/Projects/db-project/DBProject.sqlproj]
stdout: 0 Warning(s)
stdout: 1 Error(s)
I can neither find nor remember where I got this idea but I somehow got it into my head that this has something to do with the version of the SDK I'm using - I'm currently using 6.0.100, which as far as I can tell is the only one that's arm64 compatible. Every attempt I've made to download, install and run an earlier version of the SDK on this machine has failed. If that is in fact the problem, I can't even get far enough to find out.
Just to be sure it wasn't something to do with the existing project I was trying to set up, I created a brand new one from scratch and attempted to build that. It failed with the same error. It definitely appears to be a system issue and not a project-specific one.
Is there any hope for me? Am I doomed to return to working on my crummy Lenovo Thinkpad? My breath is bated. Thanks in advance.
EDIT
I've just come across the ingenious MSBuild.Sdk.SqlProj as a potential solution to my issue, however my attempts to use it are still running up against SDK version issues:
error : The current SDK bundles target framework 'netcoreapp6.0' which is not supported by MSBuild.Sdk.SqlProj. Either install a .NET Core SDK that supports 2.1, 3.1 or 5.0, or file an issue at https://github.com/rr-wfm/MSBuild.Sdk.SqlProj/ to add support.
This would seem to confirm my initial suspicion that this is an issue of SDK versions.
EDIT 2
Neglected to mention that I'm using Azure Data Studio with the SQL Database Projects extension, which purports to handle the DACPAC creation seamlessly and across platforms. Though that hasn't been my experience thus far.
I'll be dunked. I knew there had to be a deceptively simple answer to this.
It turns out that my attempts to download, install and run an earlier version of the SDK on my machine weren't failing - they were just going into a different directory. Apparently, installing x64 SDKs on an arm64 machine results in the SDKs being created in a dedicated 'x64' subdirectory of the primary dotnet installation. This is painfully obvious to me now - the reason dotnet --list-sdks showed no trace of the earlier SDKs was that they were being installed for a completely isolated instance of dotnet. All I had to do was point the SQL Database Projects extension to that instance of dotnet and it started working:
I hope my publicly blundering my way through the maze of dotnet SDK architectures manages to help someone else. For my part I'm just so relieved I've finally gotten it to work.

Error on .net core project when add Swagger (Only When Publish Project on Server)

I have a severe problem with Swagger. When I user Swagger in my project, it works perfectly on Local Machine, but when I publish the program to the server,I get error 502.
I can't find any solution for this problem.
You probably use an incompatible version of Swagger in your Project.
First, please check your installed package, and update it to the latest version.
Second, check .net runtime on your Server and update
it to the latest version.
Third, check Swagger's dependency on your
project.
app.UseOpenApi().UseSwaggerUi3();
After all, if you get the error, please send a full error description here. You can find the logged errors in the Windows event log.

Service Fabric .Net Core App - not working

I am creating a new project from Visual Studio 2015, a Service Fabric Application, picking up the one for ASP.NET Core, but it does not work when I trying to start it.
I'm running under admin power on VS, I tried to reset VS and computer, reset Service Fabric local cluster, and it's still the same. Then, It's strange but the template for API is working perfectly for me.
For me, it seems to be a problem building the executable, and then it's complaining that it doesn't found it, I took a look to the bin folder, and it's empty.
I attached a picture to describe the error:
I'd appreciate whichever advice/comment/tip/attempt to help me, thanks
EDIT: Added pic with the template which is causing the problem
EDIT: Added pic off the project.json
I'm really pissed off with this bug, I change the references to preview 1 to preview 2 and same error, Seriously nobody more has this error? I tried to uninstall and install SF SDK once again, but still the same, I need to fix it, Any ideas??
Compiling against rc2 can cause this issue.
Execute dotnet --version inside project folder to confirm.
Add global json referencing preview2 will get you up and running.

CloudConfigurationManager.GetSetting returns empty string in production?

I've just upgraded my project to Azure Tools 1.8 (October 2012 SDK) and I'm running into a strange issue;
In my WorkerRole my calls to CloudConfigurationManager.GetSetting returns null (can be empty string, hard to tell from log file). In other words; I can't fetch settings from the RoleEnvironment.
Info:
Emulator/localhost works perfect
Verified dll-version via RDP
Tried to fetch various testsettings
The same lines of code is running just fine in the production slot right now.
I'm using Microsoft.WindowsAzure.ConfigurationManager 1.8.0.0 from nuget
Added setting to app.config also to test, same result.
Any clues?
Update:
Calling code (method Run() in WorkerRole)
public override void Run(){
// Fetch connectionstring
var connectionString = CloudConfigurationManager.GetSetting("ConnectionString");
// connectionString is null here?
[...]
}
The setting is visible in the portal so it is certainly deployed.
I've fixed it, the following steps solved it:
One of the projects referenced Microsoft.WindowsAzure.Configuration version 1.7.0.0. Changed this (strange if this is the cause though since the dll in the output where the correct version. Maybe it was loaded from GAC at runtime?)
Removed assembly binding redirects for Microsoft.WindowsAzure.Configuration
Upgraded the osFamily from 1 to 2 (Windows 2008 SP2 -> Windows 2008 R2)
Some steps are probably unnecessary but I'm not sure which of them :-)
How about using RoleEnvironment.GetConfigurationSettingValue("ConnectionString") instead; assuming you are trying to get a value from service configuration file (cscfg) ?
I had the same problem. I had updated the project to use Azure SDK 2.0. I updated NuGet packages for my web and worker roles, but the Azure project in Visual Studio was still on the old version.
To fix this, Right-Click on your Azure project and select Properties. Under the Application tab, you'll see a button to Update your Azure SDK.
I got this after upgrading Azure SDK from 2.0 to 2.2. I was able to fix by:
Right-Clicking Azure project and selecting Properties. Update Azure SDK as per the Application tab. Thanks to rattrick1's answer.
Right click to Manage NuGet Packages. On the left click Updates and update WindowsAzure.ConfigurationManager.

Categories