Functions - 로컬 테스트, 디버깅 (Python)
목적
Azure Functions를 로컬에서 테스트하고 디버깅하는 방법 알아보기
준비
필요한 것
필요한 것
Azure Functions Core Tools
로컬 PC의 터미널에서 함수를 개발하고 테스트하는 도구
아래에서 설치
Azure Functions Core Tools 설치

Azure Functions의 VS Code Extension
VSCode 확장에서 설치

Azurite

Azure Storage Emulator
를 사용하려고했지만 개발 및 테스트에 Azure 스토리지 에뮬레이터 사용 에 Azurite
VSCode 확장에서 Azurite
설치
프로젝트, 함수 만들기
프로젝트 만들기
로컬 함수 프로젝트 만들기 아래에서 프로젝트 만들기( pyFunctions
는 임의의 프로젝트 이름)
터미널$ func init pyFunctions
런타임 선택이 나오므로 이번에는 파이썬을 선택

함수 만들기
함수 만들기 아래에서 함수 만들기
터미널$ func new
함수 트리거의 선택이 나오므로 이번은 HTTP trigger
와 Azure Event Grid trigger
로 작성,
각각 함수명을 httpTrigger-test
, eventGridTrigger-test
로 했다

지정된 함수 이름의 하위 폴더에 함수 코드가 생성되므로 이번에는 변경하지 않고 사용합니다.

함수 테스트
Azurite 시작
VSCode 명령 팔레트에서 Azurite:Start
실행

함수 시작
함수를 로컬에서 실행 아래에서 함수 시작
터미널$ func start
기동하면 다음과 같이 출력된다

함수 실행
이번에는 함수 실행에 Postman 사용
HTTP trigger
HTTP 및 webhook에서 트리거되는 함수 보다 이하의 URL로 함수를 실행할 수 있다
URLhttp://localhost:{port}/api/{function_name}
이하 Postman의 실행 결과

이하 터미널의 출력 결과

Azure Event Grid trigger
HTTP에서 트리거되지 않는 함수 에는 "HTTP 트리거, Webhook 트리거, Event Grid 트리거를 제외한 모든 종류의 함수의 경우 관리 엔드포인트를 호출하여 함수를 로컬에서 테스트할 수 있습니다."라고 설명되어 있으며 Event Grid 트리거 의 기재는 없고,
요청을 수동으로 게시 에 기재되어 있다
다음 설정 필요
$ func init pyFunctions
$ func new
Azurite 시작
VSCode 명령 팔레트에서
Azurite:Start
실행
함수 시작
함수를 로컬에서 실행 아래에서 함수 시작
터미널
$ func start
기동하면 다음과 같이 출력된다

함수 실행
이번에는 함수 실행에 Postman 사용
HTTP trigger
HTTP 및 webhook에서 트리거되는 함수 보다 이하의 URL로 함수를 실행할 수 있다
URL
http://localhost:{port}/api/{function_name}
이하 Postman의 실행 결과

이하 터미널의 출력 결과

Azure Event Grid trigger
HTTP에서 트리거되지 않는 함수 에는 "HTTP 트리거, Webhook 트리거, Event Grid 트리거를 제외한 모든 종류의 함수의 경우 관리 엔드포인트를 호출하여 함수를 로컬에서 테스트할 수 있습니다."라고 설명되어 있으며 Event Grid 트리거 의 기재는 없고,
요청을 수동으로 게시 에 기재되어 있다
다음 설정 필요
URL
http://localhost:7071/runtime/webhooks/eventgrid?functionName={FUNCTION_NAME}
요청 본문에는 이벤트 스키마 을 참고로 붙여넣기
이하 Postman에 헤더, 바디를 설정하여 실행한 결과


이하 터미널의 출력 결과

함수 디버깅
프로젝트 초기화
확장 기능 Azure Functions를 선택하고 initialize Project for Use with VS Code...

파이썬 선택

이하 초기화 완료 상태

디버깅
아래 Attach to Python Functions

함수가 시작되면 함수를 테스트 할 때와 마찬가지로 Postman에서 함수를 실행하면 중단 될 수 있습니다.
Reference
이 문제에 관하여(Functions - 로컬 테스트, 디버깅 (Python)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/takmot/items/90700eb0c8038d994f07
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Reference
이 문제에 관하여(Functions - 로컬 테스트, 디버깅 (Python)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/takmot/items/90700eb0c8038d994f07텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)