Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMS용 BFF 만들기 #59

Open
justinyoo opened this issue Jun 19, 2022 · 11 comments
Open

SMS용 BFF 만들기 #59

justinyoo opened this issue Jun 19, 2022 · 11 comments
Labels
oca-issue Issue that Open-source Contribution Academy involves in

Comments

@justinyoo
Copy link
Contributor

아래 두 API 합친 BFF 만들기

  • sms
  • sms-verify
@minusmo
Copy link

minusmo commented Aug 30, 2022

새로운 api를 api management에서 만든 후 inbound policy에서 다른 엔드포인트로 요청을 보내고 받은 응답을 그대로 돌려주는 것으로 생각 해보았는데요, 이런 방법으로 괜찮은지 궁금합니다!!

스크린샷 2022-08-30 오후 2 49 36
스크린샷 2022-08-30 오후 2 49 26

@justinyoo justinyoo added the oca-issue Issue that Open-source Contribution Academy involves in label Aug 30, 2022
@justinyoo
Copy link
Contributor Author

justinyoo commented Aug 30, 2022

이 문서 한 번 보실래요? 특히 set-backend-service, rewrite-uri, set-header, set-query-parameter 등을 보시면 될 것 같아요.

https://docs.microsoft.com/en-us/azure/api-management/api-management-transformation-policies

@minusmo
Copy link

minusmo commented Sep 7, 2022

멘토님! 오늘 오피스 아워에서도 질문 드리겠지만, 우선 이슈에 저희 팀이 생각한 질문을 몇가지 이슈에 올려놓겠습니다!

현재 인바운드 정책에 set-header, rewrite-uri, set-backend-service를 다음과 같이 설정해놓은 상태인데요,
image

이 상태에서 몇가지 궁금한 점이 있습니다.

  1. 현재 sms 엔드포인트에는 여러가지 하위 엔드포인트가 있는데요, 이는 템플릿 파라미터, 쿼리 파라미터에 따라(즉 요청에 따라) 달라지는데, 우리 팀은 이를 새로운 BFF 엔드포인트 인바운드 정책에서 각각 조건문(choose, when)을 써서 분기를해서, 각각 다르게 쿼리 파라미터 설정을 해서 sms와 sms-verify 백엔드 서비스로 요청을 넘기면 된다고 생각했습니다.

이것에 대해 제가 생각한 방법을 조금 더 구체적으로 말씀드리면, 저희는 BFF 엔드포인트로 들어오는 요청을 받아서 BFF/ 라는 path 뒷부분을 통으로 분리해내서, 이것을 BFF/ 만 제거한 새로운 uri로 구성한 다음에, 요청을 sms나 sms-verify 백엔드로 전달하면 된다고 생각하고 있습니다.
예) 쿼리 파라미터를 context variable에서 받아서 저장해 놓고, choose when statement를 이용해서 condition에 따라 분기를 한다.
그리고 순서는 다음과 같습니다.

  1. rewrite-uri를 이용해서 원래 sms, sms-verify가 기대하는 uri로 재구성한다.

  2. 쿼리 파라미터를 설정한다.

  3. 헤더를 설정한다.

  4. 백엔드 서비스를 설정한다.

  5. 정책이 제대로 작동하는지 빠르게 확인할 방법이 있는지 궁금합니다. 현재 정책을 애저 포탈 인바운드 폴리시에서 작성하고 있는데, 이 안의 api management expression에 대한 테스트나, 혹은 정책 전체에 대한 테스트를 빠르게 할 수 있는지?
    아니면 일단 정책을 설정한 후에, 포스트맨 같은 어플리케이션으로 응답을 확인하는 방법 밖에 없는지?
    가 궁금합니다.

아무래도 글이 길고 조금 두서 없어서 이해하기 어려우실 수도 있을 듯 합니다. 오늘 저녁 오피스 아워에서 자세히 또 여쭙겠습니다.
감사합니다!

@justinyoo
Copy link
Contributor Author

일단 제가 아는 선에서는 APIM 테스트 도구는 별도로 있지 않구요, 포탈에서 확인할 수 있습니다. 아니 할 수 있긴 한데 APIM 티어를 개발자 티어로 올려야 해서 (200불) 추천하지 않아요.

따라서, 폴리시를 셋업하고, 그 안에 보면 엔드포인트 테스트 탭이 있으니 거길 통해서 하시면 됩니다.

지금 폴리시 셋업하신 것도 괜찮긴 한데, 우리 BFF가 최종적으로 OpenAPI 문서를 내뱉어야 합니다. 그러기 위해서는 엔드포인트별로 셋업하는 게 어떨까요? 지금 상태로 해 놓으면 확인을 해 봐야 하겠지만 Swagger UI에서는 엔드포인트는 하나만 나올 것 같은데요...?

@minusmo
Copy link

minusmo commented Sep 18, 2022

@justinyoo 멘토님 질문이 있습니다!
저번에 멘토님과 논의한 내용을 따라 생각해본 이슈 해결 과정인데요, 멘토님이 설명해주신것을 제대로 이해한 것인지 궁금합니다.

  1. Open API 문서를 만든다
  2. 이 문서를 json으로 저장한다.
  3. json을 infra 폴더에 넣는다.
  4. apiManagementApi.bicep에서 service/api에서 오픈 api.json 문서를 등록한다.
  5. 여기서 api policy를 같이 등록하는데, 이 때 해당 policy.xml 문서를 등록한다.
  6. 이 폴리시 문서에서 api management expression을 이용해 서로 다른 오퍼레이션을 사용하게한다.

@justinyoo
Copy link
Contributor Author

맞습니다!

@minusmo
Copy link

minusmo commented Oct 1, 2022

@justinyoo
멘토님! Azure portal APIM configuration을 통한 정책 설정을 하고, 등록된 모든 api(총 5개)가 호출이 잘 되는지 테스트하여 잘 동작하는 것을 확인했습니다.(저는 Postman으로 확인했습니다.)

생각보다 매우 간단한 글로벌 정책 설정으로 해결했습니다.
이에 대한 스크린샷을 첨부하겠습니다.

bff apim setting

스크린샷 2022-10-01 오후 4 32 04

bff global policy setup

스크린샷 2022-10-01 오후 4 32 31.

Postman variable setup

스크린샷 2022-10-01 오후 4 23 52

SMS 상태 확인

스크린샷 2022-10-01 오후 4 39 45

SMS 발송

스크린샷 2022-10-01 오후 4 24 13

발신 번호 목록 검색

스크린샷 2022-10-01 오후 4 24 57

발송 목록 조회

스크린샷 2022-10-01 오후 4 24 45

단문 SMS 조회

스크린샷 2022-10-01 오후 4 24 27

이제는 이것을 bicep 파일과 policy 파일로 옮기는 작업이 필요해 보이는데요,
그 전에 멘토님께 질문 사항이 몇 가지 있습니다.

  • BFF 엔드포인트 네이밍(Open API 문서에 적히는 이름) 및 path 이름(BFF? or bff?)을 어떻게 정할지
  • 이를 내려받은 파일의 이름을 어떻게 정할지
    • Open API Spec json 파일의 이름
    • 글로벌 정책 xml 파일의 이름
  • apiManagementApi.bicep 파일에 bff api 리소스를 추가하는 코드를 넣는 것이 좋은지,
    따로 bff api 리소스 선언 바이셉 파일을 만드는 것이 좋은지

위의 사항들이 궁금합니다.
이것들이 정해지면, 포크한 리포지토리에서 수정을 거치고,
이 수정사항이 검토되면, CORS 추가 issue 처럼 배포 테스트를 하려합니다.

주말에 죄송합니다. ㅠㅠ
감사합니다!

@justinyoo
Copy link
Contributor Author

지난번에도 말씀드렸던 것 같은데... BFF API에서 OpenAPI 문서 익스포트해서 그게 다섯개 엔드포인트가 잘 나오나요? 이게 제일 중요합니다.

@minusmo
Copy link

minusmo commented Oct 3, 2022

@justinyoo
스크린샷 2022-10-04 오전 12 23 54

여기서 json 형식으로 문서를 export 하였는데요, 그 결과 다운로드 받아진 문서의 내용이 다음과 같습니다.

길어서 읽어보시기 어려우시리라 생각합니다. ㅠㅠ
하지만 잘 살펴보면,

  1. /sms/messages/{requestId}
  2. /sms/messages
    1. get
    2. post
  3. /sms/messages/status
  4. /sms/verify/senders
    이렇게 5개의 엔드포인트에 대한 문서임을 알 수 있습니다.
{
    "openapi": "3.0.1",
    "info": {
        "title": "BFF",
        "version": "1.0"
    },
    "servers": [
        {
            "url": "https://apim-hje-dev-krc.azure-api.net/BFF"
        }
    ],
    "paths": {
        "/sms/messages/{requestId}": {
            "get": {
                "tags": [
                    "messages"
                ],
                "summary": "Messages.Get",
                "operationId": "Messages-Get",
                "parameters": [
                    {
                        "name": "requestId",
                        "in": "path",
                        "description": "SMS request ID",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "recipientSeq",
                        "in": "query",
                        "description": "Format - int32. SMS request sequence number",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "format": "int32"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The OK response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/getMessageResponse"
                                },
                                "examples": {
                                    "sample": {
                                        "summary": "This represents the example entity for GetMessage response body.",
                                        "value": {
                                            "header": {
                                                "isSuccessful": true,
                                                "resultCode": 0,
                                                "resultMessage": "SUCCESS"
                                            },
                                            "body": {
                                                "data": {
                                                    "requestId": "2018081000000000000000000",
                                                    "requestDate": "2018-08-10T10:06:30.0000000+00:00",
                                                    "resultDate": "2018-08-10T10:06:42.0000000+00:00",
                                                    "templateId": "TemplateId",
                                                    "templateName": "TemplateName",
                                                    "categoryId": "0",
                                                    "categoryName": "CategoryName",
                                                    "body": "Body",
                                                    "sendNo": "00000000",
                                                    "countryCode": "82",
                                                    "recipientNo": "01000000000",
                                                    "msgStatus": "3",
                                                    "msgStatusName": "success",
                                                    "resultCode": "1000",
                                                    "resultCodeName": "success",
                                                    "telecomCode": 10001,
                                                    "telecomCodeName": "SKT",
                                                    "recipientSeq": 1,
                                                    "sendType": "0",
                                                    "messageType": "SMS",
                                                    "userId": "tester",
                                                    "adYn": "N",
                                                    "resultMessage": "success",
                                                    "senderGroupingKey": "SenderGroupingKey",
                                                    "recipientGroupingKey": "RecipientGroupingKey"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "The input was invalid"
                    },
                    "500": {
                        "description": "The service has got an unexpected error"
                    }
                }
            }
        },
        "/sms/messages": {
            "get": {
                "tags": [
                    "messages"
                ],
                "summary": "Messages.List",
                "operationId": "Messages-List",
                "parameters": [
                    {
                        "name": "requestId",
                        "in": "query",
                        "description": "RequestId to search. `requestId` or `startRequestDate` + `endRequestDate` or `startCreateDate` + `endCreateDate` must be filled",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "startRequestDate",
                        "in": "query",
                        "description": "Message sending request start date (`yyyy-MM-dd HH:mm:ss`)",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "endRequestDate",
                        "in": "query",
                        "description": "Message sending request end date (`yyyy-MM-dd HH:mm:ss`)",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "startCreateDate",
                        "in": "query",
                        "description": "Message sending registration start date (`yyyy-MM-dd HH:mm:ss`)",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "endCreateDate",
                        "in": "query",
                        "description": "Message sending registration end date (`yyyy-MM-dd HH:mm:ss`)",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "startResultDate",
                        "in": "query",
                        "description": "Message sending complete start date (`yyyy-MM-dd HH:mm:ss`)",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "endResultDate",
                        "in": "query",
                        "description": "Message sending complete end date (`yyyy-MM-dd HH:mm:ss`)",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "sendNo",
                        "in": "query",
                        "description": "Sender's phone number",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "recipientNo",
                        "in": "query",
                        "description": "Receiver's phone number",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "templateId",
                        "in": "query",
                        "description": "Template number",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "msgStatus",
                        "in": "query",
                        "description": "Message status code (`0`: fail, `1`: request, `2`: processing, `3`: success, `4`: Reservation cancellation, `5`: Duplicate failed)",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "resultCode",
                        "in": "query",
                        "description": "Receive result code (`MTR1`: success, `MTR2`: fail)",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "subResultCode",
                        "in": "query",
                        "description": "Receive result detail code (`MTR2_1`: Validation failed, `MTR2_2`: carrier problem, `MTR2_3`: Device problem)",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "senderGroupingKey",
                        "in": "query",
                        "description": "Sender's group key",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "recipientGroupingKey",
                        "in": "query",
                        "description": "Receiver's group key",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "pageNum",
                        "in": "query",
                        "description": "Page number in the pagination. Default value is '1'",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "pageSize",
                        "in": "query",
                        "description": "Page size in the pagination. Default value is '15'",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The OK response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/listMessagesResponse"
                                },
                                "examples": {
                                    "sample": {
                                        "summary": "This represents the example entity for ListMessages response body.",
                                        "value": {
                                            "header": {
                                                "isSuccessful": true,
                                                "resultCode": 0,
                                                "resultMessage": "SUCCESS"
                                            },
                                            "body": {
                                                "pageNum": 1,
                                                "pageSize": 15,
                                                "totalCount": 1,
                                                "data": [
                                                    {
                                                        "requestId": "2018081000000000000000000",
                                                        "requestDate": "2018-08-10T10:06:30.0000000+00:00",
                                                        "resultDate": "2018-08-10T10:06:42.0000000+00:00",
                                                        "templateId": "TemplateId",
                                                        "templateName": "템플릿명",
                                                        "categoryId": "0",
                                                        "categoryName": "카테고리명",
                                                        "body": "단문 테스트",
                                                        "sendNo": "00000000",
                                                        "countryCode": "82",
                                                        "recipientNo": "01000000000",
                                                        "msgStatus": "3",
                                                        "msgStatusName": "성공",
                                                        "resultCode": "1000",
                                                        "resultCodeName": "성공",
                                                        "telecomCode": 10001,
                                                        "telecomCodeName": "통신사",
                                                        "recipientSeq": 1,
                                                        "sendType": "0",
                                                        "messageType": "SMS",
                                                        "userId": "tester",
                                                        "adYn": "N",
                                                        "resultMessage": "",
                                                        "senderGroupingKey": "SenderGroupingKey",
                                                        "recipientGroupingKey": "RecipientGroupingKey"
                                                    }
                                                ]
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "The input was invalid"
                    },
                    "500": {
                        "description": "The service has got an unexpected error"
                    }
                }
            },
            "post": {
                "tags": [
                    "messages"
                ],
                "summary": "Messages.Send",
                "operationId": "Messages-Send",
                "requestBody": {
                    "description": "Message payload to send",
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/sendMessagesRequestBody"
                            },
                            "examples": {
                                "sample": {
                                    "summary": "This represents the example entity for SendMessages request body.",
                                    "value": {
                                        "templateId": "TemplateId",
                                        "body": "body",
                                        "sendNo": "00000000",
                                        "requestDate": "2018-08-10T10:00:00.0000000+00:00",
                                        "senderGroupingKey": "SenderGroupingKey",
                                        "recipientList": [
                                            {
                                                "recipientNo": "01000000000",
                                                "countryCode": "82",
                                                "internationalRecipientNo": "821000000000",
                                                "templateParameter": {
                                                    "key": "value"
                                                },
                                                "recipientGroupingKey": "recipientGroupingKey"
                                            }
                                        ],
                                        "userId": "UserId",
                                        "statsId": "statsId"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "The OK response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/sendMessagesResponse"
                                },
                                "examples": {
                                    "sample": {
                                        "summary": "This represents the example entity for SendMessages response body.",
                                        "value": {
                                            "header": {
                                                "isSuccessful": true,
                                                "resultCode": 0,
                                                "resultMessage": "SUCCESS"
                                            },
                                            "body": {
                                                "data": {
                                                    "requestId": "201808100000000000000000",
                                                    "statusCode": "2",
                                                    "senderGroupingKey": "SenderGroupingKey",
                                                    "sendResultList": [
                                                        {
                                                            "recipientNo": "01000000000",
                                                            "resultCode": 0,
                                                            "resultMessage": "SUCCESS",
                                                            "recipientSeq": 1,
                                                            "recipientGroupingKey": "RecipientGroupingKey"
                                                        }
                                                    ]
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "The input was invalid"
                    },
                    "500": {
                        "description": "The service has got an unexpected error"
                    }
                }
            }
        },
        "/sms/messages/status": {
            "get": {
                "tags": [
                    "messages"
                ],
                "summary": "Messages.Status",
                "operationId": "Messages-Status",
                "parameters": [
                    {
                        "name": "startUpdateDate",
                        "in": "query",
                        "description": "StartDate for message list (`yyyy-MM-dd HH:mm:ss`)",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "endUpdateDate",
                        "in": "query",
                        "description": "endDate for message list (`yyyy-MM-dd HH:mm:ss`)",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "messageType",
                        "in": "query",
                        "description": "message type (`SMS`/`LMS`/`MMS`/`AUTH`)",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "pageNum",
                        "in": "query",
                        "description": "Page number in the pagination. Default value is '1'",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "pageSize",
                        "in": "query",
                        "description": "Page size in the pagination. Default value is '15'",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The OK response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/listMessageStatusResponse"
                                },
                                "examples": {
                                    "sample": {
                                        "summary": "This represents the example entity for ListMessageStatus response body.",
                                        "value": {
                                            "header": {
                                                "isSuccessful": true,
                                                "resultCode": 0,
                                                "resultMessage": "SUCCESS"
                                            },
                                            "body": {
                                                "pageNum": 1,
                                                "pageSize": 15,
                                                "totalCount": 1,
                                                "data": [
                                                    {
                                                        "messageType": "SMS",
                                                        "requestId": "2018081000000000000000000",
                                                        "recipientSeq": 1,
                                                        "resultCode": "1000",
                                                        "resultCodeName": "success",
                                                        "requestDate": "2018-08-10T10:06:30.0000000+00:00",
                                                        "resultDate": "2018-08-10T10:06:42.0000000+00:00",
                                                        "updateDate": "2018-10-04T16:17:15.0000000+00:00",
                                                        "telecomCode": "10003",
                                                        "telecomCodeName": "LGU",
                                                        "senderGroupingKey": "SenderGroupingKey",
                                                        "recipientGroupingKey": "RecipientGroupingKey"
                                                    }
                                                ]
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "The input was invalid"
                    },
                    "500": {
                        "description": "The service has got an unexpected error"
                    }
                }
            }
        },
        "/sms/verify/senders": {
            "get": {
                "tags": [
                    "senders"
                ],
                "summary": "Senders.List",
                "operationId": "Senders-List",
                "parameters": [
                    {
                        "name": "sendNo",
                        "in": "query",
                        "description": "Sender's phone number",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "useYn",
                        "in": "query",
                        "description": "Value indicating whether the number is used or not",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "blockYn",
                        "in": "query",
                        "description": "Value indicating whether the number is blocked or not",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "pageNum",
                        "in": "query",
                        "description": "Page number in the pagination. Default value is '1'",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "pageSize",
                        "in": "query",
                        "description": "Page size in the pagination. Default value is '15'",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The OK response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/listSendersResponse"
                                },
                                "examples": {
                                    "sample": {
                                        "summary": "This represents the example entity for GetMessage response body.",
                                        "value": {
                                            "header": {
                                                "isSuccessful": true,
                                                "resultCode": 0,
                                                "resultMessage": "SUCCESS"
                                            },
                                            "body": {
                                                "pageNum": 1,
                                                "pageSize": 15,
                                                "totalCount": 2,
                                                "data": [
                                                    {
                                                        "serviceId": 1234,
                                                        "sendNo": "01012345678",
                                                        "useYn": "Y",
                                                        "blockYn": "N",
                                                        "blockReason": null,
                                                        "createDate": "2020-01-01T00:00:00.0000000+00:00",
                                                        "createUser": "18ad9058-6466-48ef-8a78-08c27519ac24",
                                                        "updateDate": "2020-01-01T00:00:00.0000000+00:00",
                                                        "updateUser": "18ad9058-6466-48ef-8a78-08c27519ac24"
                                                    },
                                                    {
                                                        "serviceId": 5678,
                                                        "sendNo": "01087654321",
                                                        "useYn": "Y",
                                                        "blockYn": "N",
                                                        "blockReason": null,
                                                        "createDate": "2020-01-01T00:00:00.0000000+00:00",
                                                        "createUser": "18ad9058-6466-48ef-8a78-08c27519ac24",
                                                        "updateDate": "2020-01-01T00:00:00.0000000+00:00",
                                                        "updateUser": "18ad9058-6466-48ef-8a78-08c27519ac24"
                                                    }
                                                ]
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "The input was invalid"
                    },
                    "500": {
                        "description": "The service has got an unexpected error"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "getMessageResponse": {
                "type": "object",
                "properties": {
                    "header": {
                        "$ref": "#/components/schemas/responseHeaderModel"
                    },
                    "body": {
                        "$ref": "#/components/schemas/responseItemBodyModel_getMessageResponseData"
                    }
                }
            },
            "getMessageResponseData": {
                "type": "object",
                "properties": {
                    "requestId": {
                        "type": "string"
                    },
                    "requestDate": {
                        "type": "string"
                    },
                    "resultDate": {
                        "type": "string"
                    },
                    "templateId": {
                        "type": "string"
                    },
                    "templateName": {
                        "type": "string"
                    },
                    "categoryId": {
                        "type": "string"
                    },
                    "categoryName": {
                        "type": "string"
                    },
                    "body": {
                        "type": "string"
                    },
                    "sendNo": {
                        "type": "string"
                    },
                    "countryCode": {
                        "type": "string"
                    },
                    "recipientNo": {
                        "type": "string"
                    },
                    "msgStatus": {
                        "type": "string"
                    },
                    "msgStatusName": {
                        "type": "string"
                    },
                    "resultCode": {
                        "type": "string"
                    },
                    "resultCodeName": {
                        "type": "string"
                    },
                    "telecomCode": {
                        "type": "integer",
                        "format": "int32"
                    },
                    "telecomCodeName": {
                        "type": "string"
                    },
                    "recipientSeq": {
                        "type": "integer",
                        "format": "int32"
                    },
                    "sendType": {
                        "type": "string"
                    },
                    "messageType": {
                        "type": "string"
                    },
                    "userId": {
                        "type": "string"
                    },
                    "adYn": {
                        "type": "string"
                    },
                    "resultMessage": {
                        "type": "string"
                    },
                    "senderGroupingKey": {
                        "type": "string"
                    },
                    "recipientGroupingKey": {
                        "type": "string"
                    }
                }
            },
            "listMessagesResponse": {
                "type": "object",
                "properties": {
                    "header": {
                        "$ref": "#/components/schemas/responseHeaderModel"
                    },
                    "body": {
                        "$ref": "#/components/schemas/responseCollectionBodyModel_listMessagesResponseData"
                    }
                }
            },
            "listMessagesResponseData": {
                "type": "object",
                "properties": {
                    "requestId": {
                        "type": "string"
                    },
                    "requestDate": {
                        "type": "string"
                    },
                    "resultDate": {
                        "type": "string"
                    },
                    "templateId": {
                        "type": "string"
                    },
                    "templateName": {
                        "type": "string"
                    },
                    "categoryId": {
                        "type": "string"
                    },
                    "categoryName": {
                        "type": "string"
                    },
                    "body": {
                        "type": "string"
                    },
                    "sendNo": {
                        "type": "string"
                    },
                    "countryCode": {
                        "type": "string"
                    },
                    "recipientNo": {
                        "type": "string"
                    },
                    "msgStatus": {
                        "type": "string"
                    },
                    "msgStatusName": {
                        "type": "string"
                    },
                    "resultCode": {
                        "type": "string"
                    },
                    "resultCodeName": {
                        "type": "string"
                    },
                    "telecomCode": {
                        "type": "integer",
                        "format": "int32"
                    },
                    "telecomCodeName": {
                        "type": "string"
                    },
                    "recipientSeq": {
                        "type": "integer",
                        "format": "int32"
                    },
                    "sendType": {
                        "type": "string"
                    },
                    "messageType": {
                        "type": "string"
                    },
                    "userId": {
                        "type": "string"
                    },
                    "adYn": {
                        "type": "string"
                    },
                    "resultMessage": {
                        "type": "string"
                    },
                    "senderGroupingKey": {
                        "type": "string"
                    },
                    "recipientGroupingKey": {
                        "type": "string"
                    }
                }
            },
            "listMessageStatusResponse": {
                "type": "object",
                "properties": {
                    "header": {
                        "$ref": "#/components/schemas/responseHeaderModel"
                    },
                    "body": {
                        "$ref": "#/components/schemas/responseCollectionBodyModel_listMessageStatusResponseData"
                    }
                }
            },
            "listMessageStatusResponseData": {
                "type": "object",
                "properties": {
                    "messageType": {
                        "type": "string"
                    },
                    "requestId": {
                        "type": "string"
                    },
                    "recipientSeq": {
                        "type": "integer",
                        "format": "int32"
                    },
                    "resultCode": {
                        "type": "string"
                    },
                    "resultCodeName": {
                        "type": "string"
                    },
                    "requestDate": {
                        "type": "string"
                    },
                    "resultDate": {
                        "type": "string"
                    },
                    "updateDate": {
                        "type": "string"
                    },
                    "telecomCode": {
                        "type": "string"
                    },
                    "telecomCodeName": {
                        "type": "string"
                    },
                    "senderGroupingKey": {
                        "type": "string"
                    },
                    "recipientGroupingKey": {
                        "type": "string"
                    }
                }
            },
            "listSendersResponse": {
                "type": "object",
                "properties": {
                    "header": {
                        "$ref": "#/components/schemas/responseHeaderModel"
                    },
                    "body": {
                        "$ref": "#/components/schemas/responseCollectionBodyModel_listSendersResponseData"
                    }
                }
            },
            "listSendersResponseData": {
                "type": "object",
                "properties": {
                    "serviceId": {
                        "type": "integer",
                        "format": "int32"
                    },
                    "sendNo": {
                        "type": "string"
                    },
                    "useYn": {
                        "type": "string"
                    },
                    "blockYn": {
                        "type": "string"
                    },
                    "blockReason": {
                        "type": "string"
                    },
                    "createDate": {
                        "type": "string"
                    },
                    "createUser": {
                        "type": "string"
                    },
                    "updateDate": {
                        "type": "string"
                    },
                    "updateUser": {
                        "type": "string"
                    }
                }
            },
            "responseCollectionBodyModel_listMessagesResponseData": {
                "type": "object",
                "properties": {
                    "pageNum": {
                        "type": "integer",
                        "format": "int32",
                        "nullable": true
                    },
                    "pageSize": {
                        "type": "integer",
                        "format": "int32",
                        "nullable": true
                    },
                    "totalCount": {
                        "type": "integer",
                        "format": "int32",
                        "nullable": true
                    },
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/listMessagesResponseData"
                        }
                    }
                }
            },
            "responseCollectionBodyModel_listMessageStatusResponseData": {
                "type": "object",
                "properties": {
                    "pageNum": {
                        "type": "integer",
                        "format": "int32",
                        "nullable": true
                    },
                    "pageSize": {
                        "type": "integer",
                        "format": "int32",
                        "nullable": true
                    },
                    "totalCount": {
                        "type": "integer",
                        "format": "int32",
                        "nullable": true
                    },
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/listMessageStatusResponseData"
                        }
                    }
                }
            },
            "responseCollectionBodyModel_listSendersResponseData": {
                "type": "object",
                "properties": {
                    "pageNum": {
                        "type": "integer",
                        "format": "int32",
                        "nullable": true
                    },
                    "pageSize": {
                        "type": "integer",
                        "format": "int32",
                        "nullable": true
                    },
                    "totalCount": {
                        "type": "integer",
                        "format": "int32",
                        "nullable": true
                    },
                    "data": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/listSendersResponseData"
                        }
                    }
                }
            },
            "responseHeaderModel": {
                "type": "object",
                "properties": {
                    "isSuccessful": {
                        "type": "boolean"
                    },
                    "resultCode": {
                        "type": "integer",
                        "format": "int32"
                    },
                    "resultMessage": {
                        "type": "string"
                    }
                }
            },
            "responseItemBodyModel_getMessageResponseData": {
                "type": "object",
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/getMessageResponseData"
                    }
                }
            },
            "responseItemBodyModel_sendMessagesResponseData": {
                "type": "object",
                "properties": {
                    "data": {
                        "$ref": "#/components/schemas/sendMessagesResponseData"
                    }
                }
            },
            "sendMessagesRequestBody": {
                "type": "object",
                "properties": {
                    "templateId": {
                        "type": "string"
                    },
                    "body": {
                        "type": "string"
                    },
                    "sendNo": {
                        "type": "string"
                    },
                    "requestDate": {
                        "type": "string"
                    },
                    "senderGroupingKey": {
                        "type": "string"
                    },
                    "recipientList": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/sendMessagesRequestRecipient"
                        }
                    },
                    "userId": {
                        "type": "string"
                    },
                    "statsId": {
                        "type": "string"
                    }
                }
            },
            "sendMessagesRequestRecipient": {
                "type": "object",
                "properties": {
                    "recipientNo": {
                        "type": "string"
                    },
                    "countryCode": {
                        "type": "string"
                    },
                    "internationalRecipientNo": {
                        "type": "string"
                    },
                    "templateParameter": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "object"
                        }
                    },
                    "recipientGroupingKey": {
                        "type": "string"
                    }
                }
            },
            "sendMessagesResponse": {
                "type": "object",
                "properties": {
                    "header": {
                        "$ref": "#/components/schemas/responseHeaderModel"
                    },
                    "body": {
                        "$ref": "#/components/schemas/responseItemBodyModel_sendMessagesResponseData"
                    }
                }
            },
            "sendMessagesResponseData": {
                "type": "object",
                "properties": {
                    "requestId": {
                        "type": "string"
                    },
                    "statusCode": {
                        "type": "string"
                    },
                    "senderGroupingKey": {
                        "type": "string"
                    },
                    "sendResultList": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/sendMessagesResponseResult"
                        }
                    }
                }
            },
            "sendMessagesResponseResult": {
                "type": "object",
                "properties": {
                    "recipientNo": {
                        "type": "string"
                    },
                    "resultCode": {
                        "type": "integer",
                        "format": "int32"
                    },
                    "resultMessage": {
                        "type": "string"
                    },
                    "recipientSeq": {
                        "type": "integer",
                        "format": "int32"
                    },
                    "recipientGroupingKey": {
                        "type": "string"
                    }
                }
            }
        },
        "securitySchemes": {
            "apiKeyHeader": {
                "type": "apiKey",
                "name": "Ocp-Apim-Subscription-Key",
                "in": "header"
            },
            "apiKeyQuery": {
                "type": "apiKey",
                "name": "subscription-key",
                "in": "query"
            }
        }
    },
    "security": [
        {
            "apiKeyHeader": []
        },
        {
            "apiKeyQuery": []
        }
    ]
}

@justinyoo
Copy link
Contributor Author

@justinyoo 멘토님! Azure portal APIM configuration을 통한 정책 설정을 하고, 등록된 모든 api(총 5개)가 호출이 잘 되는지 테스트하여 잘 동작하는 것을 확인했습니다.(저는 Postman으로 확인했습니다.)

수고하셨습니다!

이제는 이것을 bicep 파일과 policy 파일로 옮기는 작업이 필요해 보이는데요, 그 전에 멘토님께 질문 사항이 몇 가지 있습니다.

  • BFF 엔드포인트 네이밍(Open API 문서에 적히는 이름) 및 path 이름(BFF? or bff?)을 어떻게 정할지
  • 이를 내려받은 파일의 이름을 어떻게 정할지

기존의 다른 API들은 어떻게 되어 있던가요? 그걸 참조해서 같은 식으로 하시면 될 겁니다. API에 보이는 이름은 BFF, suffix(혹은 path)는 bff일 거예요.

  • Open API Spec json 파일의 이름

이건 bff.v3.json 으로 할까요?

  • 글로벌 정책 xml 파일의 이름

이전 policy 파일의 이름 포맷은 어땠나요?

  • apiManagementApi.bicep 파일에 bff api 리소스를 추가하는 코드를 넣는 것이 좋은지,
    따로 bff api 리소스 선언 바이셉 파일을 만드는 것이 좋은지

apiManagementApi.bicep 파일을 그대로 활용할 수 있을 겁니다. 한 번 확인해 보세요.

위의 사항들이 궁금합니다. 이것들이 정해지면, 포크한 리포지토리에서 수정을 거치고, 이 수정사항이 검토되면, CORS 추가 issue 처럼 배포 테스트를 하려합니다.

실제로 이게 제대로 작동이 되는지 확인해 보려면 Azure CLI 명령어를 통해 배포해 보시면 됩니다.

주말에 죄송합니다. ㅠㅠ 감사합니다!

@minusmo
Copy link

minusmo commented Oct 20, 2022

@justinyoo

  • apiManagementApi.bicep 파일에 bff api 리소스를 추가하는 코드를 넣는 것이 좋은지,
    따로 bff api 리소스 선언 바이셉 파일을 만드는 것이 좋은지

apiManagementApi.bicep 파일을 그대로 활용할 수 있을 겁니다. 한 번 확인해 보세요.

이부분에서 멘토님이 이야기하신 apiManagementApi.bicep을 그대로 활용한다는 것이 무엇인지 잘 모르겠어서 다시 질문드립니다!

바이셉 파일을 읽어보니 원래는 functionApp 과 리소스를 배포하고, 그에 맞는 api를 provisioning 하는 과정인데,
새로운 bff는 실제로 functionApp을 만드는 것이 아니잖아요?
그러면 suffixes에 'bff'를 추가하고, suffix가 'bff'일 때는 functionApp이나 다른 리소스를 생성하지 않고
api provisioning만 할 수 있게 하는 코드를 main.bicep과 setup-apim.sh 을 수정하면 되는 것인가요?

  • main.bicep 에서는 suffix가 bff면 functionApp은 생성하지 않고 deploymentScript 로만 제어를 넘기고,
  • setup-apim.sh에서도 suffx가 bff면 기존의 az deployment 명령이 아니라 functionApp이 없는 채로 배포 하도록
    명령을 수정해야한다고 생각하고 있습니다.

그리고 apim-setup.sh 마지막에 스웨거 문서를 추출해서 스토리지 어카운트에 저장하는 명령에
api_name 이 sms 밖에 없는데 sms verify 스웨거 문서는 어떻게 추출되는 것인지 잘 모르겠습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
oca-issue Issue that Open-source Contribution Academy involves in
Projects
None yet
Development

No branches or pull requests

2 participants