-
Notifications
You must be signed in to change notification settings - Fork 447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functions using custom extensions work in emulator but fail indexing when deployed (c#, v2.0.12050.0) #3386
Comments
I'm having the same problems! |
If you move your extension to a different project, and reference this project the problem is solved. The IWebJobStartup in your functions assembly is ignored in the published extensions.json. (you can verify this in obj/release/pubTmp/bin) |
Great, thanks @mlankamp, that fixed it. So that's a workaround - who can escalate this so that IWebJobStartup implementations are detected in the main function app binary? |
This is not limited to custom extensions. I am encountering the same issue with the C# CosmosDB binding here: Microsoft.Azure.WebJobs.Extensions.CosmosDB. Unfortunately, there is nothing to move to another project so there is no workaround. |
I've been running into this as well. The build generates the correct extensions.json in bin\Release\netstandard2.0\bin. So, I created a build target Directory.Build.targets file that can be dropped into the project directory and will copy the correct file at publishing time. This will copy the correct extensions.json into the publish directory prior to actual deployment/zipping etc... |
Thanks @dbarentine for the workaround. Does anyone know if there a fix in the pipeline? |
this worked for me but will this be fixed ? |
Awesome. Worked like charm for me after 3 days of struggle in making the Function App run on the server. Was running smoothly in my local system, except on the server. Thanks again. |
Thanks @dbarentine Fixed my issue |
@fabiocav Any updates or an ETA on this issue? When developing and running locally in VS2017, the following target frameworks produce same output as specified by @stevedenman
|
FYI. With .NET Core 2.1 target, build with the latest VS 2017 doesn't produce proper extensions.json (no "Startup" entry). At the same time, "dotnet build" executed from Ubuntu environment (on the same Windows 10 machine) against the same project folder produces proper extensions.json. |
This fails for me in the emulator as well as when deployed targeting anything above .NET Core 2.0 Has the cause been identified? |
OK, sorry I'm an AF noob, I apologize if this is not the same topic but it looks like it might be . . . I have been attempting to implement this package, my function signature / DI: ([HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req, [Willezone.Azure.WebJobs.Extensions.DependencyInjection.Inject] ILogger logger, [Willezone.Azure.WebJobs.Extensions.DependencyInjection.Inject] DataLakeClientFactorySource dataLakeClientFactory) works fine in my dev environment but when published is throwing a 500 error. This also works fine when published: ( [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req, [Willezone.Azure.WebJobs.Extensions.DependencyInjection.Inject] ILogger logger) So the code fails on line 3, the custom class injection (line 2 ILogger is MSFT). Is this the same problem, failing to publish an extension file? |
This bug prevented proper functions parsing by Azure (everything worked locally). This has something to do with the target framework. See Azure/azure-functions-host#3386
Manually creating the two files in the function root fixed my binding issue, files here: Directory.Build.targets
extensions.json
Also, don't forget to copy extensions.json to output dir
Then run
Troubleshooing Then you may have to delete the following lines: [yourpath]\obj\ActiveMQFunctionUsageExample.csproj.nuget.g.targets Then run this again
|
This is a horrible situation. Any words from Microsoft about this issue
state?
|
I can't seem to get this to work. I have two other functions, and the only difference i can find is the httptrigger. Nevermind, When i switched my build agent in Azure DevOps to Hosted Ubuntu it started working. |
i followed what Fowler said at and it started working on my machine (osx). When I build and push to azure, it is not working with my custom extension (its an httpClient getting injected). I checked the extensions.json and its is NOT empty on the server that is failing. thoughts?! |
@tommyk The problem is not that extensions.json is empty, on server it contains only few built in stuff and none of the additional extensions you have in the project (including your custom http client). You can check this by creating a new empty AF project and building it so that extensions.json is created for it and compare against that. |
@DaliborTakac agreed not ideal |
@fabiocav I confirm that referencing Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator in the latest version (1.0.2 as of now) resolved the issue. Tested when publish from VS and Azure DevOps (both using Web Deploy). My runtime is: <TargetFramework>netcoreapp2.1</TargetFramework> And libraries: <PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.0.3" />
<PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.0.2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />
<PackageReference Include="Willezone.Azure.WebJobs.Extensions.DependencyInjection" Version="1.0.1" /> Also to clarify, even with the latest metadata geneeator I still had to keep the Directory.Build.targets. Without that target the |
This bug prevented proper functions parsing by Azure (everything worked locally). This has something to do with the target framework. See Azure/azure-functions-host#3386
I can confirm this is fixed with latest Sdk 1.0.26.
My question is - am I allowed to do use target framework netcoreapp2.2 yet? |
I just updated to the latest Microsoft.NET.Sdk.Functions (version 1.0.26, which includes 1.0.2 of the MetadataGenerator), and that seems to solve the issue for us. However, I do not need the Directory.Build.targets that @zarusz is referencing to in order to have the DI functional. Might be due to the use of |
I've added the recommended Build.Targets file, but this didn't fix it for me. I installed Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator v1.1.0 and the latest version of Microsoft.NET.Sdk.Functions (1.0.27). The extensions.json file looks correct and is present in the publish directory. However I'm getting an error when I call my function (Exception binding parameter {dependencyName} -> NullReferenceException). The weird thing is I have a second function (basic hello function) that has a dependency on another service. This function executes successfully. I don't understand why the parameter binding works for one function and not for the other. |
@louisekeegan It sounds like your dependency object fails during construction, probably some uninitialised variable in the constructor? |
@louisekeegan this looks like a different issue. If you can open a separate issue and point to a repro, it will be easier to investigate |
@bobvandevijver yes, you're on the right track. It appears my issue was due to my assumption that my settings.json file was getting published with the app (I'm new to Azure functions). My Startup class needed to read this file to create an instance of a settings class and then register it with the DI container. My guess is I was registering null. Lesson learned :) |
@fabiocav looks like it was my mistake so no need to investigate any further. Thanks! |
I am still facing this issue unfortunately using I have a custom startup.cs that is registered and generates correctly when running locally. When I use VS 2017 to deploy to Azure, I can see it generates a {
"extensions":[
]
} I can see that the correct I have tried including I am loathed to have to follow the suggestion by @ElliotWood as, although it may work, the framework should handle this directly and our build numbers change which would require additional steps to keep the Can anyone confirm if this is an ongoing issue and if there is either a time-frame for a fix or a viable workaround? Update |
For some reason I missed this suggestion from @dbarentine earlier, and with a small tweak to the Still interested to know when this workaround will no longer be required. |
@marshall76963 (and others still having issues when using Micrsosoft.Net.Sdk.Functions 1.0.28) -- can you try running a build without your custom build targets, and add the "/bl" flag to the build command line? That will generate an msbuild.binlog file. If you could email that to me (my microsoft email is in my github profile), that'd give us a better picture as to what's going on. |
@brettsam - I have emailed you with the binlog file - thanks for supporting me on this :) |
For those of you still seeing issues with 1.0.28, can you try:
It looks like the direct reference re-orders some things during a publish, which causes the extensions.json generator to miss the functions assembly. That's something we can fix, but removing the package reference should get rid of the ordering problem. |
I just randomly started seeing this issue. I think the cause was that I added a AspNet NetFramework package to something, when it was expecting Core stuff (removing obviously does not fix my issue). Now my extension no longer starts up. Suggestions such as re-adding it elsewhere does not resolve my issue. @brettsam When I peek inside the temp dirs and look in the project.assets.json, I can find references to ExtensionsMetadataGenerator. I don't quite know how to read this:
But I'd assume it mean it's the functions package which is pulling in your suspect package. I am on 1.0.29 btw. I don't see any extensions.json file either in any output dir which seems to contain the right thing. |
Following the recent update (2.0.12050.0) I made the change suggested here, using IWebJobsStartup to add extensions, however functions that use these extensions are not being indexed when deployed (works in emulator).
Investigative information
Please provide the following:
Repro steps
Provide the steps required to reproduce the problem:
I deployed to a new function app with a custom extension registered in IWebJobsStartup, but no functions could be indexed;
Expected behavior
All functions are indexed.
Actual behavior
It looks like the custom extensions are not being loaded.
Known workarounds
Related information
Test project here; https://github.com/stevedenman/azure-functions-v2-di/tree/master/AzureFunctionV2DI
The text was updated successfully, but these errors were encountered: