Deploying Your Bot¶
Prerequisites¶
- Account on Docker Hub (Sign up at https://hub.docker.com/)
- Azure subscription (Sign up at https://azure.microsoft.com/en-us/free/)
Instructions¶
Linux Web App¶
- From Azure Portal (portal.azure.com) spin up a Linux Web App
- Log in to Docker locally (
docker login
and enter your credentials for Docker Hub) - Build the docker image from the bot’s Dockerfile (you can name the image anything you wish, here it’s
flaskbot
). For example:
docker build -f Dockerfile -t flaskbot:latest .
docker images
- Tag the image with the Docker Hub username (replace <dockeruser> with your docker user name and give the image name) and tag:
docker tag <image id> <dockeruser>/flaskbot
- Push up the docker image to Docker Hub (takes some time):
docker login
docker push <dockeruser>/flaskbot
- Specify the docker image to the Linux Web App (give the app a name, replacing <mybotname>, resource group, replacing <mybotrg>, and point to the image):
az login
az webapp config container set --name <mybotname> --resource-group <mybotrg> --docker-registry-server-url <dockeruser>/flaskbot
- Navigate to portal and click on Docker Container in left panel to ensure the app is pulling in the correct image from Docker Hub.
- Check that the endpoint is working:
- Navigate to http://<your web app name>.azurewebsites.net/api/messages and should get a Method Not Allowed http error (because GET not allowed here - but this message indicates the flask app is running)