.NET 5 Azure Function 격리 프로세스가 정적 클래스, 정적 메서드인 이유

.NET 5 격리프로세스 형태로 Azure Function를 생성하게되면 static class에 static method로 Run 메서드가 생성됩니다. 하지만 습관적으로 static을 모두 삭제하고 테스트해봤더니 문제없이 동작하여 왜 static이 기본 생성탬플릿이고 꼭 필요한지 질문했습니다.

image

Like you’ve mentioned, both work and its completely up to you. Originally, only static functions were supported and later support for instance functions were added.
Dependency Injection requires non-static classes but for most simpler use cases, you could get away with static classes. For example, simple transformations, routing scenarios, etc.

이렇다고 하시네요. 그냥 static 없이 쓰셔도 될 것 같습니다.

1개의 좋아요

답변을 수락하고 나면 원본 링크가 되네요. 원본 링크 올립니다.

Azure Function Trigger Basic Code Template Style - Microsoft Q&A

그리고 static class를 사용하지 않아야, 생성자 주입을 통해서 Generic Host의 장점을 이용할 수 있으니, static class로 안 쓰는 것이 좋을 것 같습니다.

1개의 좋아요