question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Breaking change in ExtensionConfigContext

See original GitHub issue

As noted here a lot of dependency injection stuff is build that relies on getting the JobHostConfiguration from the ExtensionConfigContext. With the new beta8 package the Config is gone. This is the old beta5 code:

public class ExtensionConfigContext : FluentConverterRules<Attribute, ExtensionConfigContext>
{
    public ExtensionConfigContext();

    public JobHostConfiguration Config { get; set; }

    public FluentBindingRule<TAttribute> AddBindingRule<TAttribute>() where TAttribute : Attribute; 
    [Obsolete("preview")]
    public Uri GetWebhookHandler();
    }

Now we are not able to build an Inject binding to inject certain dependencies into our functions. Like we did before:

public class InjectConfiguration : IExtensionConfigProvider
{
	public void Initialize(ExtensionConfigContext context)
	{
		var rule = context
					.AddBindingRule<InjectAttribute>()
					.Bind(new InjectBindingProvider());

		var registry = context.Config.GetService<IExtensionRegistry>();

		var filter = new ScopeCleanupFilter();
		registry.RegisterExtension(typeof(IFunctionInvocationFilter), filter);
		registry.RegisterExtension(typeof(IFunctionExceptionFilter), filter);
	}
}

Do you have any alternatives for dependency injection? And if so please show an example.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:36 (1 by maintainers)

github_iconTop GitHub Comments

14reactions
jnevins-gcmcommented, Sep 12, 2018
<!--
  When doing a Pack, MS extensions metadata generator calls  _GenerateFunctionsExtensionsMetadataPostPublish...
  but _GenerateFunctionsExtensionsMetadataPostPublish actually executes before the function dll itself (i.e. AzureFunctionApp.dll) has been copied
  to the publish dir by _FunctionsPostPublish. This target copies the AzureFunctionApp.dll to the publish dir much earlier so that the extensions metadata
  generator finds it when it searches dlls for extensions (i.e. IWebJobsStartup implementations).
  -->
  <Target Name="CopyTargetPathToEarlyPublish" BeforeTargets="Publish">
    <Copy SourceFiles="$(TargetPath)" DestinationFiles="$(FunctionsTargetPath)" />
  </Target>

12reactions
DibranMuldercommented, Sep 6, 2018

I have published an example in this repository: https://github.com/DibranMulder/azure-functions-v2-dependency-injection

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Functions v2 Breaking Change for custom bindings
However, your CustomBindings will be broken. I'd like to share some simple step how to migrate your current Custom Bindings to adopt the...
Read more >
Named services support, fixes for breaking changes
Breaking change in ExtensionConfigContext · Subtle differences in DI between WebJobs.Script.WebHost and Microsoft.Azure.WebJobs/Microsoft.
Read more >
Azure Functions 2.0 extensibility - overview
Information about Azure Functions 2.0 extensibility are available, but scattered. This post attempts to gather the key aspects.
Read more >
Versioning in Durable Functions (Azure Functions)
The most fail-proof way to ensure that breaking changes are deployed safely is by deploying them side-by-side with your older versions. This can ......
Read more >
Calling Azure Function calls fail with "Function host is not ...
The message with it is: Repository has more than 10 non-decryptable secrets backups (host). I unfortunately have no idea what that means. Any ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found