Deploying Microsoft Bot Framework bots using Kubernetes on Azure Container Service (ACS)

Creating a bot

app.js

Deploying the bot to a local Docker container

Dockerfile
BOTNAME=echobotdocker build -t $BOTNAME ~/path/to/bot
HOSTPORT=3978CONTAINERPORT=3978docker run -p 127.0.0.1:$HOSTPORT:$CONTAINERPORT -name $BOTNAME -t $NAME

Updating bot with SSL certificates

modified app.js

Creating our Kubernetes cluster

RESOURCE_GROUP=my-resource-groupLOCATION=eastusaz group create --name=$RESOURCE_GROUP --location=$LOCATION
DNS_PREFIX=some-unique-valueSERVICE_NAME=any-acs-service-nameaz acs create -orchestrator-type=kubernetes -resource-group $RESOURCE_GROUP -name=$SERVICE_NAME -dns-prefix=$DNS_PREFIX

Controlling the Kubernetes cluster manager

az acs kubernetes install-cli

Configuring kubectl

az acs kubernetes get-credentials

Deploying bot to Docker Registry or Azure Container Registry

Setting up for Docker Hub:

docker login

Setting up ACR:

REGISTRY_NAME=your-registry-nameaz acr create -g $RESOURCE_GROUP -n $REGISTRY_NAME -l eastusaz ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/${SUBSCRIPTION_ID}"docker login -u <app-id> -p <password> registry-microsoft.azurecr.io
$USERNAME=your-usernamedocker imagesdocker tag <container-id> $USERNAME/$BOTNAME:latestdocker push $USERNAME/$BOTNAME

Deploying to Kubernetes on Azure Container Service (ACS)

echobot-deployment.yaml
kubectl create -f echobot-deployment.yaml --record
kubectl get pods
$PODNAME=name-of-podkubectl describe pods $PODNAME

Creating and exposing a service

kubectl create -f echobot-service.yaml --record
kubectl get svc
pending public IP assignment
we have a public IP 🚀
kubectl exec -ti $PODNAME -- bash
kubectl logs $PODNAME

Creating environment variables as Kubernetes secrets to secure the service

echo -n "your-app-id" | base64
echobot-secrets.yaml
kubectl create -f echobot-secrets.yaml --record

Cleanup

kubectl delete deployment,service,secret echobot

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sertaç Özercan

Sertaç Özercan

Software Development Engineer @Microsoft @Azure