Skip to content

[Question] Best practices ServiceClient & Dependency Injection #311

Closed

Description

Do you have any guidance / best practices when using the ServiceClient in web applications or function apps? These will use dependency injection. Kind of similar to what was done for the HttpClient.

So basically: What is the correct way of using the ServiceClient with Dependency Injection in web applications?

Activity

  1. jordimontana82 commented on Sep 5, 2022

    @jordimontana82
  2. MattB-msft commented on Sep 5, 2022

    @MattB-msft
    Member

    Yep. this is on the "To-Do" list for samples for the client,
    also, we are internally testing a few different extensions for Dependency injection, one of which we may add to the client in the future.

  3. mVermaat commented on Sep 6, 2022

    @mVermaat
    Author

    Good to know, thanks for the information. With the current constraints, what is the best approach? I know I can make it 'work' by implementing something like in the link. However I'm not sure what the consequences are for using in example Scoped or Singleton.

  4. MattB-msft commented on Sep 6, 2022

    @MattB-msft
    Member

    Scoped or Singleton uses cases are situational, IE, what are you trying to accomplish in the function or asp.net core app.
    We do not have a strong opinion on it and are using both processes in different services.

    Mainly what we are testing is memory and isolation management options for us in API services (function and the like), when running at scale over a long period of time. Once we settle on a specific approach, we will build it into the client as an extension. In the meantime, we may provide a sample or 2 on the PowerApps Samples site based on current work.

  5. locked and limited conversation to collaborators on Sep 7, 2022
  6. converted this issue into a discussion #312 on Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions