How to debug a legacy Azure function - azure

I've been given the task to debug an Azure function on VS 2022 targeting .Net Framework 4.8. While its straight forward to debug it in .Net Core 3.0 or later, I keep getting the error - A project with an Output Type of Class Library cannot be started directly, when I try to run it by pressing F5. Looking around, I followed this link to download Azure functions core tools; https://github.com/Azure/azure-functions-core-tools but it hasn't worked even after restarting VS.The function has following properties:
While I can run and debug functions written in .Net Core 3.1 and .Net 6 but I'm struggling with this legacy function. Any help is really appreciated.

We have tried to create Azure function with .net framework 4.8 and successfully tested in our local by using visual studio 2022.
We have installed azure function core tool 4x on our local. Make sure that only one azure function core tool has installed on our local.
Created one azure function with http trigger by selecting .net framework and targeting it to version 4.8.
Able to debug successfully as shown below
For more information please refer this MICROSOFT DOCUMENTATION

Related

Azure app service container crash with "Could not load file or assembly" on ASP.NET Core MVC .NET 6

I am trying to deploy my .NET 6 asp.net core web app but I'm getting a weird error when trying to do so:
I don't understand why it is searching for .NET 7 packages when my project and stack is on 6.
I tried ZIP deploy through VS and automated through GitHub to no avail. My app worked fine the other day all I did was switch to a Basic B1 plan from Standard S1 to reduce cost.
I think the problem is related to your Github Actions. You're building the entire solution, but your project EasyRank.Tests.Common uses a different version of Microsoft.EntityFrameworkCore 7.0.0, while the others are using 6.0.10. Internally it has a dependency on Microsoft.Extensions.DependencyInjection.Abstractions and they are conflicting.

Azure function in Java, http layer generated based on openapi

I saw https://azure.microsoft.com/en-in/updates/generate-a-new-function-app-from-an-openapi-specification/
so in VSCode v1.63.2, azure functions plugin v1.6.0
but when I go to azure extension and then "Create new project" when I select Java I dont have any option to choose template ( http trigger ) but in Java I dont see this option ..
Anyone had maybe similar issue ?
thanks
To create a Java Azure Function with HTTP Trigger in VS CODE we need to configure as our environment as given here .
Java Development Kit, version 11 or 8.
Apache Maven, version 3.0 or above.
Visual Studio Code on one of the supported platforms.
The Java extension pack
The Azure Functions extension for Visual Studio Code.
As we have already configured the same in our environment, We have created One Azure Function using java which is using HTTP trigger.
In VS CODE for java when you will follow this Microsoft Documentation you can able to Create an Azure function using java with http trigger by providing the details.
SCREENSHOT FOR REFERENCE:-
For more information please refer this MICROSOFT DOCUMENTATION: Develop Azure Functions by using Visual Studio Code

Unable to publish the azure functions

We have a Azure Function which is built in .Net Framework 4.6 and recently we have updated the Azure Functions with .Net Framework 4.8 which works good in locally. So we tried to publish this to Live by going to select the existing Azure Function as below image.
But we are unable to publish due to below error (Publish has encountered an error).
Can you please suggest me If I missed any settings/configuration.
As far as i know, azure function v1 support dotnet framework4.7 as the document shows:
I test it in my side with dotnet framework 4.8 and show the same error message as you, so i think you'd better change the dotnet framework from 4.8 to 4.7.

Azure app service Configuration ambiguity

I've uploaded an asp.net core app with VS 2019 publish, and targeted the app netcoreapp2.2.
The app worked perfectly, but when checking some performance issue, I've noticed that in Azure portal-Configuration-General settings, the app stack settings was .NET (not .net core), and version is V4.7.
This raises 2 questions:
1. How is it even working...?
2. Why VS deployment process wasn't configured with the settings displayed in publish section?
VS publish settings:
Azure settings:
Thanks!
I fixed the issue by updating the following lines in .sln
from:
Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
To:
# Visual Studio Version 16
VisualStudioVersion = 16.0.30011.22
ASP.NET Core 2.x can target .NET Core or .NET Framework. ASP.NET Core apps targeting .NET Framework aren't cross-platform—they run on Windows only. Generally, ASP.NET Core 2.x is made up of .NET Standard libraries. Libraries written with .NET Standard 2.0 run on any .NET platform that implements .NET Standard 2.0.
When you published to the .NET Core 2.2 runtime app you would always get the following warning message:
"There was a problem starting MyProjectName on MyWebAppServiceName. Your application requires the .NET Core 2.2.0 runtime, but Microsoft Azure App Service only support the following versions:.
One way to fix this problem is by changing the deployment mode to self-contained in the publish settings, which will allow the application to carry its own runtime."
Refer to this similar case.
Edit:
When you create webapp on portal, you could go to arm template to get the stack setting which is set as CurrentStack: dotnetCore. But when you publish project on VS, it could net set the runtime.
So, it may a VS issue that you could give feedback or you could create webapp on Azure first which set runtime as .Net Core and publish project to it using VS.

Target .NET Core 2.0 with Azure Functions in Visual Studio 2017

Since Microsoft has released .NET Core 2.0 for Azure Functions a few days ago, I'm trying to understand how to create a new Functions project in VS2017 targeting .NET Core.
I've tried many configurations and still ended up with .NET 4.7.
Did anyone manage to create a new Function targeting .NET Core?
Thanks.
This is supported with the 1.0.5 release of the Microsoft.NET.Sdk.Functions package.
In your Azure Functions Project, do the following:
Update the Microsoft.NET.Sdk.Functions package version to 1.0.5
Right click on your project, click the Edit <projectname>.csproj option and modify the TargetFramework element value to netstandard2.0
This will should generate .NET Standard 2.0 assemblies with all the artifacts created by the Azure Functions tooling.
As of today I have been able to target .Net Standard 2.0 in a "reasonably" intuitive way and without editing any .csproj files.
You need a reasonably recent version of Visual Studio. I'm using Visual Studio Professional 15.5.3 (although I would guess that community would work).
You need to have the Azure development workload installed. This will install an extension called Azure Functions and Web Jobs Tools.
So far so plain vanilla. There were 2 additional bits that were to me not at all intuitive but ended up being very easy to do - easy when you know how!
You need to make sure that the Azure Functions and Web Jobs Tool is 15.0.31114.0 or greater - that's when they added .net core 2.0 support (see https://github.com/Azure/Azure-Functions/blob/master/VS-AzureTools-ReleaseNotes.md). You can update this using Tools/Extensions and Updates, or see https://marketplace.visualstudio.com/items?itemName=VisualStudioWebandAzureTools.AzureFunctionsandWebJobsTools
Even when you've done that, Visual Studio is a tiny bit weird about letting you create Azure Functions that target .net 2.0. When you go File/New Project, nothing has changed in the list of available project types, and if you select Azure Functions, the list of Frameworks just shows .NET Framework *, no .NET Standard, no .NET Core.
But if at this point you persevere and select Azure Functions, you then get a new dialog I hadn't seen before, which allows you to select Azure Functions v2 Preview (.NET Core).
Now, when I then look at the project properties, it turns out it is targeting .NET Standard 2.0, which in turn seems to contain Microsfot.NETCore.Platforms (1.1.0). So is this .net core 2.0 or not? Not quite sure but its' good enough for my purposes so now going to tuck into some coding.
Cheers!
For now, it's a manual process. You need to create .NET Standard 2.0 library, add function.json manually and run it with core tools.
the package Microsoft.NET.Sdk.Functions does not yet support .NET Standard 2.0 class libraries. This is the package that identifies a project as Functions project to Visual Studio and generates function.json from attributes during build.
You can still author C# class libraries that target .NET Standard 2.0, but you must use a manually-authored function.json. The templates for C# class libraries aren’t yet available in the Core Tools, but you can get a sample from GitHub.
from Develop Azure Functions on any platform
Update: 1.0.5 version of SDK should now support it, as mentioned by Fabio.

Resources