Mac에서 개발한 봇을 Azure에서 운영

개요



Microsoft Bot Framework를 사용하여 만든 봇을 Microsoft Azure에서 게시하는 방법은 다음 문서를 참조하십시오.

Build2016 : Microsoft Bot Framework를 사용하여 Bot 앱 만들기
htps : // bgs. msd 응. mic로소 ft. 이 m / b ㅅ 스카이 / 2016/04/01 / 부이 ld2016

하지만 이 기사에서는 Visual Studio 2015를 사용하기 때문에 Mac에서 개발한 봇을 Azure에 올리려면 몇 가지 걱정할 점과 절차가 있습니다.
이 기사에서는 그것을 소개합니다.

봇 만들기



Microsoft Bot Framework를 사용하여 봇을 만드는 단계는 다음 문서를 참조하십시오.

「MS 근제의 bot 작성 프레임워크 「botbuilder」로 놀아 보았다! "
ぃ tp // m / 0h / ms / 1 a 51cd0bd9c38027388

위 기사 중에서는 파일명을 "slack.js"로 하고 있습니다만, Azure(App Service)가 Node.js 프로그램이라고 인식시키기 위해서는 이것을 "server.js"로 할 필요가 있습니다.

또한 설치 시 다음 패키지를 추가로 설치해야 하는 것 같습니다. (이것은 Azure이기 때문에)
npm install --save botkit

Azure에 올라가기 전에 한 번 로컬에서 동작을 확인해 봅시다.
112-233:botexample y.furukawa$ token=$SLACK_BOT_TOKEN node server.js
info: ** No persistent storage method specified! Data may be lost when process shuts down.
info: ** Setting up custom handlers for processing Slack messages
info: ** API CALL: https://slack.com/api/rtm.start
notice: ** BOT ID: botexample ...attempting to connect to RTM!



좋아요!

Azure에 봇을 올리기



먼저 App Service에 새 환경을 만듭니다.

순서는 하기 페이지를 일부 참고로 했습니다.

Azure App Service에서 Node.js 웹 앱 사용
htps : // 오즈레. mic로소 ft. 코 m / 자 jp / 도쿠 멘 타치 온 / 아 rc c ぇ s / 아 p せ r

Azure CLI에서 로그인합니다.
Azure CLI를 포함하지 않으면 설치합니다. 설치 방법은 상기 기사 참조.
112-233:botexample y.furukawa$ azure login
Microsoft Azure CLI would like to collect data about how users use CLI
(中略)
info:    login command OK
112-233:botexample y.furukawa$ azure site create --git botexample1
info:    Executing command site create
+ Getting sites
+ Getting locations
help:    Choose a location
  1) South Central US
  2) North Europe
  3) West Europe
  4) Southeast Asia
  5) East Asia
  6) West US
  7) East US
  8) Japan West
  9) Japan East
  10) East US 2
  11) North Central US
  12) Central US
  13) Brazil South
  14) Canada Central
  15) Canada East
  : 8

적당히 근장(8:Japan West)을 선택했습니다.
info:    Creating a new web site at botexample1.azurewebsites.net
-info:    Created website at botexample1.azurewebsites.net
+
info:    Executing `git init`
(中略)
info:    Creating default iisnode.yml file
info:    Initializing remote Azure repository
+ Updating site information
info:    Remote azure repository initialized
+ Getting site information
+ Getting user information
info:    Executing `git remote add azure https://[email protected]/botexample1.git`
info:    A new remote, 'azure', has been added to your local git repository
info:    Use git locally to make changes to your site, commit, and then use 'git push azure master' to deploy to Azure
info:    site create command OK
112-233:botexample y.furukawa$

Git 리포지토리가 생성되었습니다.
코드를 커밋하고 푸시하면 배포할 수 있는 것이군요. 간단!

그건 그렇고, 처음 실행할 때 이러한 오류가 발생했습니다.
help:    You must create your git publishing credentials using the Microsoft Azure portal

웹 UI에서 설정> 배포 자격 증명에서 배포 사용자 이름과 암호를 설정하고 azure site create --git botexample1를 다시 실행하여 환경 만들기를 완료했습니다.



그럼 실제로 배포합니다.
112-233:botexample y.furukawa$ git add .
112-233:botexample y.furukawa$ git commit -m "create server.js"
(中略)
112-233:botexample y.furukawa$ git push azure master
(中略)
remote: Deployment successful.
To https://[email protected]/botexample1.git
 * [new branch]      master -> master

웹 UI로 돌아가서 설정> 응용 프로그램 설정> 응용 프로그램 설정에서 환경 변수 token을 설정합니다.



어떤 프레임 워크에서 Node.js 프로젝트를 만들면 package.json이 만들어져 자동으로 모듈이 설치 될 것입니다. 그러나 샘플 코드 파일 만 있으면 Error: Cannot find module 'botkit'와 같은 오류가 발생합니다.
그러므로 별로 바람직한 형태는 아니지만 node_modules 아래의 파일 세트도 커밋 & 푸시합니다.
112-233:botexample y.furukawa$ vi .gitignore
node_modules 의 행을 삭제합니다.
112-233:botexample y.furukawa$ git add .
112-233:botexample y.furukawa$ git commit -m "add node_modules"
(中略)
112-233:botexample y.furukawa$ git push azure master

그렇다면 server.js가 실행되지 않기 때문에 한 번에 두드러집니다.
GET http://botexample1.azurewebsites.net/

응답은 반환되지 않지만 이제 봇이 발생하고 메시지를 반환합니다. 했어!

좋은 웹페이지 즐겨찾기