Azure Function Version Affecting GET Request - azure

When I try to set Azure Functions to stable versions 1.0.14 or 1.0.13 locally & in the Portal - I tend to receive a 500 error when trying to GET an endpoint. Through some debugging, I managed to correct this by changing the version to beta. No errors.
Has anyone else seen this issue? Is there any way around this without actually having to recreate the function using the desired version?
Thank you!

You probably mistake Azuer Function SDK version for Azure Function Runtime version.
try to set Azure Functions to stable versions 1.0.14 or 1.0.13 locally & in the Portal
1.0.14 or 1.0.13 you mentioned is SDK version(latest is 1.0.19 right now), which is used to build our function project. Of course we can't set SDK version on portal as build is done before we publish pre-compiled code to Azure. If we develop in browser, the build process and SDK version(the latest) is under the control of Azure.
I managed to correct this by changing the version to beta. No errors.
You may have created a v2 function locally, hence function depends on beta runtime. And you specify a wrong version of 1.x like 1.0.14, so 1.0.11959 is used. We can see 500 error is caused by mismatched runtime and you have corrected it. If you have planned to work with v2 function(.net standard), nothing malfunctions so far.
And some more info about function runtime version.
Function Runtime version
There are two major versions: 1.x for .Net Framework and 2.x for .Net Standard.
Syntax
Major version :~1 for 1.x , ~2 for 2.x. With this format, function app on Azure is automatically updated to new minor versions of the runtime when they become available.
Minor version 1.x:1.0.11959; 2.x: 2.0.11961-alpha, 2.0.12050-alpha. (All versions available right now). Function app on Azure is kept on that version until we explicitly change it.
Where to find
Runtime version in Function app settings.
FUNCTIONS_EXTENSION_VERSION in Application settings.
Configuration
Two scenarios we need to change runtime.
Major version change. ~1 to ~2 or reverse.
We may see prompt below if there are functions in the app.
Major version upgrades can introduce breaking changes to languages and bindings. When upgrading major versions of the runtime, consider creating a new function app and migrate your functions to this new app.
In an empty function app(delete existing functions or create new app), change runtime in Function app settings.
We can directly set FUNCTIONS_EXTENSION_VERSION in Application settings if published project depends on another runtime.
Minor version pinned to avoid breaking changes(probably the last time to use as 2.x is planned to be GA by this fall).
See breaking changes in 2.0.12050-alpha(beta), we can pin FUNCTIONS_EXTENSION_VERSION to 2.0.11961-alpha and follow steps to work with changes and move to beta.
Find more breaking changes to fix if our 2.x function runtime is pinned to some older version, which have all been removed on Azure.
Wrong version handler
If we specify a wrong version of 1.x like 1.0.14, Azure will leverage latest minor version instead. It is same with 2.x.
For local dev
Commonly speaking, local dev doesn't need runtime configuration because we choose Cli first(using tools like npm or VS does in background), we are clear about the major version at least.
Some local places to find function runtime version.
VS, New Function project v1 or v2.
VS/VSCode c# function, in functionappname.csproj, see <AzureFunctionsVersion>v2</AzureFunctionsVersion>.
VSCode, functionapp/.vscode/setting.json, see "azureFunctions.projectRuntime": "~2"
Function core tools(Cli), run func, we may see Function Runtime Version:2.0.12050.0
Start a function app in VS/VSCode/Cli, besides 4, we can also see Cli output Starting Host (HostId=xx, InstanceId=xx, Version=2.0.12050.0, ..)

Very useful information, thank you Jerry! I managed to solve my issue by recreating the Azure function without using .NET Standard. Azure lets you know that changing certain settings may lead to the function not working properly. After recreating with the proper runtime set in both portal and project, it worked.

Related

Update function runtime version of QueueTrigger function application in azure

I have queueTrigger azure functions. I am receiving warning about function runtime version update. To update runtime version, I have followed some steps like I update value of "FUNCTIONS_EXTENSION_VERSION" key to "~4" and check "Function runtime settings" tab where Runtime version showing as custom(~4)
Also I update versions inside setting.json file of function application and update "extensionBundle" version values in host.json file
After updating those files, I update function by docker deployment. But it still showing me warning about runtime version update.
I had updated runtime version of another function app which has httpTrigger trigger functions.
As you can also there is some UI difference also between Function runtime settings tabs of both function applications (In 1st Runtime version is with custom string and in 2nd it without that string). In this queueTrigger function app its not updating runtime version as it still showing warning. Is it something which I doing wrong? How can I update it then? Can someone help me regarding this?
Deployed the Python Versioned 3.6 Azure Function Version 3 basic Http Trigger using VS Code:
This is my settings.json of the above project:
{
"azureFunctions.deploySubpath": ".",
"azureFunctions.scmDoBuildDuringDeployment": true,
"azureFunctions.pythonVenv": ".venv",
"azureFunctions.projectLanguage": "Python",
"azureFunctions.projectRuntime": "~3",
"debug.internalConsoleOptions": "neverOpen"
}
According to MSFT Doc of Azure Functions Version & Python Compatibility, Python 3.6 Version is compatible to AFCT (Azure Functions Core Tools) Version 3 only.
Upgrade Process:
In Azure Portal Function app > Configuration > Function Runtime Settings > Runtime version set 3 to 4.
You have to upgrade the Python Version in Local Project along with code changes that are compatible to AFCT Version 4 and Python Versions (>3.7).
This MS Doc of Upgrading Python AF Local Project clearly explains what has to updated before upgrading to the AFCT Version 4.
Note: AF - Azure Function, AFCT - Azure Functions Core Tools
I fixed this issue by making change in Dockerfile. Previously I was pulling "mcr.microsoft.com/azure-functions/python:3.0-python3.8" docker image. I have changed this image to "mcr.microsoft.com/azure-functions/python:4-python3.8" which fix this issue.

Problems migrating Node.js Azure Function from Function Extensions 2.x to 3.x

So, I've inherited an Azure Function App written in Node.js from a contractor who did a little work for us. This piece of code was developed outside our C# stack, so I'm having to go back and maintain it.
I'm trying to update the Azure Function Extensions runtime for the project in Visual Studio Code, however it seems to be ignoring the local.settings.json for my development environment, and no matter which flags I set, it continues to run the 2.x runtime.
And when it runs, I'm seeing the following errors:
However the documentation they're referencing has zero information about migrating from 2.x to 3.x other than that it 'will be seemless in most cases'.
And of course, the function app won't run:
The problem ended up being the version of the core tools running on my development VM.
As per the documentation here, the core tools version needs to be installed (x64 version for VS Code).
In spite of the fact that I setup this Dev VM yesterday, it still needed to have the core tools version updated to the latest. Once I updated it, it was able to spin up the function locally as expected.

Azure Functions Upgrade from beta to ~2 breaking existing code

We have been using Azure Function runtime version as "beta" and Microsoft.Azure.WebJobs.Extensions.EventHubs - version 3.0.0-beta5 package to bind with Eventhubs.
Things broke down completely after azure portal started prompting for Upgrading to version 2 for Azure Functions. With or without changing the runtime to ~2 (or any specific 2.x.x.x version) it is failing.
Can someone make it clear on what needs to change if we want to target version 2? I tried to upgrade Microsoft.NET.Sdk.Functions to latest 1.0.19 and Microsoft.Azure.WebJobs.Extensions.EventHubs to latest 3.0.0-beta8. All I get is assembly loader errors!
Please help!
You can find the description of this breaking change and recommended steps in this issue.

HttpRequestMessageExtensions not being found at run-time in Azure Function

I've got an Azure Function app that creates a precompiled DLL (so it uses normal .cs files, not the older .csx method, pre-VS2017). Previously, it was targeting .Net Framework 4.5.2. I updated it to 4.7 so as to use some of the new C# 7 features. I updated my NuGet packages by doing "Update-Package -Reinstall" and verified that they all have the "net47" target set in my packages.config file.
Everything compiles fine. But when I call a function that uses either of 2 HttpRequestMessageExtensions methods, I get an exception. One example of the exception is this:
Method not found: 'System.Net.Http.HttpResponseMessage
System.Net.Http.HttpRequestMessageExtensions.CreateResponse(
System.Net.Http.HttpRequestMessage, System.Net.HttpStatusCode)'.
Here's an example of a tiny test function that will cause the error:
using System.Net;
using System.Net.Http;
public static HttpResponseMessage Run(HttpRequestMessage req)
{
return req.CreateResponse(HttpStatusCode.Accepted, "");
}
Upon calling this function with say Postman, I'll receive the aforementioned exception. I also get a similar method not found exception when I call GetQueryNameValuePairs() on the HttpRequestMessage.
I've tried updating my NuGet packages to the latest, no difference. I've cleaned and rebuilt and restarted a bunch of times, making sure to nuke my bin and obj directories.
I'm not sure what could be the problem. I guess I could downgrade back to .Net 4.5.2 but I'd rather not. For one, I want to use C# 7, and for two, I want to understand what the problem is rather than avoid it.
Update: interesting. The issue seems to be with System.Net.Http. If I lower it to 4.0.0 everything works fine. If I raise it to any higher version I get the issues listed above. I tried selectively lowering each of my packages, one by one, to their previous version number to find this out. I then updated all but this one to the latest version and it fixed the issue.
I also tested it on my side. The issue is related to the latest version of System.Net.Http assembly(4.3.2). If I don't install this package manually or install the earlier versions(4.3.1/4.3.0), the application could work fine.
The CreateResponse method is a extension method which is written in System.Web.Http assembly(version 5.2.3). It seem that it is not compatible with the latest version of System.Net.Http. Please could just skip the error by using the earlier version of System.Net.Http and you can also submit this issue to Microsoft using follow channel.
https://connect.microsoft.com/VisualStudio/Feedback
Interesting. For me, if I got above version 4.0.0 (including 4.1.1 or 4.3.1) I still get the same problem of not finding those extension methods.
The assembly might not be updated during you change the package version. From the bin\Debug\net47 folder, we could check the current assembly version we used.
If the modified date of assembly is 2/9/2017, the package version is 4.3.1. If the modified date of assembly is 4/19/2017, the package version is 4.3.2. If the assembly is not the latest version, it could work fine on my side.
In addition, Microsoft.Asp.Net.WebApi.Client package is installed by default when creating an Azure function. System.Net.Http is one of its dependencies. So we don't need to install the System.Net.Http package manually. When running our application, NuGet will choose a right version of System.Net.Http for our application.
I had the same issue running my Azure Function locally and eventually tracked it down to conflicting System.Net.Http assemblies. I created my Azure function from a blank ASP.NET Web App and initially pulled down the System.Net.Http NuGet package to use within the project. I also pulled down the Microsoft.AspNet.WebApi.Client for use within the project. It did not matter which version of System.Net.Http I tried my project would compile but fail when the request was made.
Eventually, I removed packages I had downloaded, cleaned the build folder and added just the Microsoft.AspNet.WebApi.Client. I noticed that this automatically referenced the System.Net.Http on my machine for my version of the .NET Framework. (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework). This compiled successfully and I was able to make requests to the function without any exceptions.
Using #Aaron-Newton's insight, I identified that my issue was due to my Azure Functions project referencing a .Net Standard 2.0 class library. I switched it to .Net Framework 4.6 and it started working again. Seems like this is a bug in the Functions tooling.
I've filed a bug with the Functions team here: https://github.com/Azure/Azure-Functions/issues/477
I had the same issue. I spent quite a while to fix this problem.
The cause is that the Azure Functions project is refering to .Net Standard Library with version higher than 1.4.
Bringing down your .Net Standard version to 1.4 or lower would fix the problem.
But this is defintely a bug with Azure Functions SDK. They should fix it.
https://github.com/Azure/azure-webjobs-sdk-script/issues/980
https://github.com/Azure/Azure-Functions/issues/477

Changing version of Azure Storage

I am a beginner in Azure and have come across a task to change the storage version.I basically found that the versions are obsolete and need to upgrade them as per http://blogs.msdn.com/b/windowsazurestorage/archive/2014/08/05/microsoft-azure-storage-service-version-removal.aspx
So, in one of the paragraphs its mentioned
"What to change
If you find any log entries which show that version to be removed is being used, you will need to find that component and either validate that it will continue to work (unversioned requests may continue to work as their implicit version will simply increase – see above), or take appropriate steps to change the version being used. Most commonly, one of the following two steps will be used:
1) Change the version specified in the request, typically by migrating to a later version of the libraries/tools. When possible, migrate to the latest version to get the most improvements and fixes.
2) Set the default service version to one of the supported versions now so that the behavior can be verified prior to removal. This only applies to anonymous requests with no explicit version. "
Question is, how to go about implementing point 1 and 2 ?
Thanks
Since your code is written in C# and uses Azure SDK your best bet is to upgrade it to a "new enough" SDK. It's unclear whether version 2.0 or 2.1 is the lowest required. So your route is the following:
First, check if you really have to do anything.
You check which Azure SDK your service uses. If it's 2.1 or higher you don't need to worry yet. If your're unsure - use Fiddler to validate the version headers as explained in the linked to post.
If you use Azure SDK 2.0 you'd better check the version headers as explained in the linked to post.
If you use Azure SDK prior to 2.0 you are surely affected and have to upgrade.
So if you found you do need to upgrade you'll have to download and install the newer SDK and then remove references to old SDK assemblies from your projects and add references to new SDK assemblies. Then you try to build your code and maybe fix a lot of calls because SDK interfaces have changed (that's what I see migrating from 1.8 to 2.4). Once it builds you test it works fine and then you remove the old SDK version to ensure the code builds without it present.
There was a breaking change between 2.1 and 2.2 - the latter only support Visual Studio 2012 and higher. There was another set of changes in Azure Diagnostics functioning between 2.4 and 2.5 which are so long to read that I chose to migrate to 2.4 instead of 2.5.

Resources