Azure Functions - Referencing the same library as the CLI - azure

I'm working on a precompiled C# Azure Function, and I want to reference a lot of the Microsoft.Extensions dlls. The current version is 2.1.1 for most of these.
However, when I run the project, I get an assembly load error. This seems to be caused by the folder the func.exe file is in comes with most of these dlls, but at version 2.0.0.
If I reference version 2.0.0, then everything works. But is there a way to not have to reference the exact same version as the cli?

This version conflict has been fixed in new version cli. See this related issue and SO thread.
This should be resolved on the latest version of the Azure Functions runtime (2.0.11888, CLI 2.0.1-beta.31).
Have done some tests with Microsoft.Extensions.Configuration 2.1.1. Works as expected.
To consume the latest cli,
If you use Visual Studio to debug,
update Azure Functions and Web Jobs Tools(in menu Tools>Extensions and Updates) to latest version 15.0.40617.0. After update, create a new Azure Function project, wait at the create dialog for VS to download new cli and template.
After a while, we can see the tip change to
On Windows, check whether this folder%LocalAPPDATA%\AzureFunctionsTools\Releases\2.2.2exists, which contains 2.0.1-beta.31 cli. If the downloading fails, just delete %LocalAPPDATA%\AzureFunctionsTools folder and restart VS to download again.
If you use npm, npm i -g azure-functions-core-tools#core --unsafe-perm true. For more choices, see cli installation.

Related

Could not load file or assembly 'Microsoft.Azure.WebJobs.Host, Version=3.0.22.0

I have recently cloned a new repository which has AzureFunctions but I am unable to run it. The build succeeds and on Run click it opens a window suggesting that it is downloading Azure
I am using VS2017 and .Net core 2.1.
It seems to be working for other team members but not for me.
I keep getting this 'Could not find Azure.WebJobs.Host...' error continuously.
I've tried all the fixes that are there on the internet without any luck.
The Azure Functions and Web job tools dlls seem to be up-to-date as they are not shown in the updates tab.
Updating all the nuget dependencies also did not work.
I tried using VS2017 and .Net core 2.1.
Installed Microsoft.Azure.WebJobs - 3.022 version from Nuget Packages.
Included Namespace
using Microsoft.Azure.WebJobs.Host;
I found that there is no Microsoft.Azure.WebJobs.Host direct assembly to include.
If you install Microsoft.Azure.WebJobs you can directly use Microsoft.Azure.WebJobs.Host namespace.
Check your .csproj , if you have any PackageReference Included with Microsoft.Azure.WebJobs.Host, try to remove and build your Application.
It must include Microsoft.Azure.WebJobs

Build works locally and fails in Azure

I have a project in C Sharp which build correctly in my local machine ( as well as in the one from my colleagues ). But when we try to configure the pipeline in Azure, in the step of Nuget restore everything stops and we get an error message stating that package "A" is not compatible with netcore 2.2, as well as package B,C,D,etc.
Why is it possible to see this error in Azure but not in my local? The project is setup to use netcore 2.2 and builds fine in my local machine.
Why is it possible to see this error in Azure but not in my local? The project is setup to use netcore 2.2 and builds fine in my local machine.
This error can occur with an outdated version of nuget. The default version of NuGet running in the VSTS pipeline was not the latest one.
So, to resolve this issue, there is a nuget version installer task which you can run as part of your build step to upgrade the version of nuget running in your build pipeline:
Besides, if update nuget version not resolve this issue, please check the SDK version on the build agent is same as your local, you can use the task Use .NET Core to update the SDK version.
Hope this helps.

Azure DevOps Build Solution using wrong version of package

I've got a 'Build Solution' step for a ASP.NET project in Azure DevOps and it's failing because it's trying to use an old version of a package. In my code it's only referenced in the packages.config and I've changed that entry to use version 1.0.7, but in Azure DevOps it's still trying to find 1.0.2 but fails to find it. Any ideas why it's trying to use the wrong package version or how to force it to get the new one? My project in visual studio has no references to the old version.
There were references in the .csproj file that were trying to access the old file path, and that version of the package did not exist at that path. So I took the bad path out and it fixed the issue
Probably one of your NuGet packages requires version 1.0.2 of the package. To figure out which one, delete the local version 1.0.2 and build the solution locally. Then take a look at the build output and see which package is missing that version. Maybe take a look here:
Increase Build Log Verbosity to Get More Details About a Build Problem

Azure Functions - Event Hub Trigger - Beta Version /V2

I'm trying to use the beta version/V.2 (I'm using the Microsoft Graph API) of the Azure Functions creating an Event Hub Trigger for an IoT device. However, I get an error just installing the extensions. "Extensions not Installed - Microsoft.Azure.WebJobs.Extensions.EventHubs".
We were not able to install the runtime extension. To learn more please view https://functionsmeetingroom.scm.azurewebsites.net/api/vfs/data/Functions/extensions/f5728d04-0b6c-4514-a780-43d6faddc4fd.json
Why? Please let me know
Try adding an explicit entry to your .csproj file.
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="3.0.0-beta5" />
This worked for me.
Extension installation via portal is not very consistent. Your app is can get into a bad state without much effort. To fix it you could follow the steps mentioned here.
https://github.com/Azure/app-service-announcements/issues/94#issuecomment-376647094
Update extensions.csproj with latest version of the nuget package, look up nuget.org for the latest version of extensions
Microsoft.NET.Sdk.Functions
Microsoft.Azure.WebJobs.Extensions.CosmosDB
Microsoft.Azure.WebJobs.Extensions.DurableTask
Microsoft.Azure.WebJobs.Extensions.MicrosoftGraph
Microsoft.Azure.WebJobs.Extensions.* (Everything Else)
Follow these steps to fix a function app written in the portal:
Stop the function app.
Access kudu console through Platform Features -> Advanced Tools -> Debug Console (cmd)
Navigate to d:\home\site\wwwroot
Delete the bin directory
Edit extensions.csproj
Update with the appropriate versions (see above)
Run dotnet build extensions.csproj -o bin --no-incremental --packages D:\home.nuget
Start the function app

Unable to build Compiled Azure Function in VSTS (Error MSB4019)

I have created an Azure Function using the latest build of visual studio 2017 (15.3.1).
This build allows me to do the:
New Project > Azure Function App approach
This produces a .csproj (not a .funproj file) and it's doesn't come bundled with a website or anything. I've tried .Net 4.6 and 4.6.1 as the target framework and neither have worked.
I get the following error in VSTS:
C:\Users\Builder.nuget\packages\microsoft.net.sdk.functions\1.0.2\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Publish.props
(13, 3)
C:\Users\Builder.nuget\packages\microsoft.net.sdk.functions\1.0.2\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Publish.props(13,3):
Error MSB4019: The imported project "C:\Program Files (x86)\Microsoft
Visual
Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\Sdk\Sdk.Props"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk.
There is no node in my .csproj file so I am not sure where it is getting that from.
I'm using the latest NuGet option in VSTS, I'm using the Latest VS Version option as well.
The build steps are:
Get Sources
NuGet Restore
Build Solution (MSBuild.exe exited with code '1' every time)
Is there any way to build (and then release) compiled .Net functions in VSTS at the minute?
I was able to solve this by swapping the build agent from the "Default" group to the latest, "Hosted VS 2017" group, and that has compiled fine.
Looks like the machine is missing the latest dotnet cli. I'm not too familiar with VSTS build machines, but you'd need to get that on there somehow https://www.microsoft.com/net/download/core

Resources