0

I'm creating a new Azure Functions with a Queue trigger. A key requirement is for me to use my existing class libraries that I created in my ASP.NET Core app so that I can access my Repository methods. I also have my own clients that handle communication with some third party services.

I need help with creating instances of my clients and passing configuration to them which is IConfiguration.

Here's what my Startup.cs looks like in my Azure Functions project:

using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using MyApp.Infrastructure.Clients;
using MyApp.Infrastructure.Interface;
using MyApp.Infrastructure.Repositories;

[assembly: FunctionsStartup(typeof(MyTestFunction.Startup))]
namespace MyTestFunction
{
    public class Startup : FunctionsStartup
    {
        public IConfiguration Configuration { get; }

        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.Services.AddSingleton(new MyApp.Infrastructure.Clients.MyClient123(Configuration));
            builder.Services.AddTransient<ICommunicationsRepository, CommunicationsRepository>();
        }
    }
}

In my ASP.NET Core app's Startup.cs, I do have a constructor that handles the configuration -- see below -- but not sure how to handle this Azure Functions.

public Startup(IConfiguration configuration)
{
     Configuration = configuration;
}

public IConfiguration Configuration { get; }
0

1 Answer 1

1

Looks like this is not a recommended approach: https://github.com/Azure/azure-functions-host/issues/4464#issuecomment-513017446

I've decided to update my class libraries in my ASP.NET Core app so that I use Azure KeyVault in both my API and Azure Functions apps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.