Previous: Data analysis | Next: Clean up
-
Move to the app folder and update the configuration file
app/tedapp/config.py
using the values you retrieved during database setup:Variable Value COSMOSDB_ENDPOINT
Your Cosmos DB endpoint COSMOSDB_KEY
Your Cosmos DB primaryMasterKey
In addition, set
SECRET_KEY
to the output of the following command:import os os.urandom(24)
-
Build a Docker image:
docker build --network=host -t tedapp .
-
Run the Docker image in a container:
docker run -d --name tedcontainer --network=host tedapp
-
Verify that you can access the app at http://localhost
-
Stop and remove the container:
docker container stop tedcontainer docker container rm tedcontainer
- Create a new container registry:
az acr create --name gicampanacr --sku Basic --admin-enabled true
- Retrieve the name of the login server:
az acr list --query "[].{acrLoginServer:loginServer}" --output table
- Log in:
az acr login --name gicampanacr
- Tag the Docker image:
docker tag tedapp gicampanacr.azurecr.io/tedapp:v1
- Push the Docker image to the container registry:
docker push gicampanacr.azurecr.io/tedapp:v1
- Verify that the image was successfully uploaded:
az acr repository list --name gicampanacr --output table
- Create an App Service plan:
az appservice plan create --name gicampan-service-plan --is-linux --sku B1
- Create a Web App:
az webapp create --name gicampan-ted-explorer \ --plan gicampan-service-plan \ --deployment-container-image-name gicampanacr.azurecr.io/tedapp
- Retrieve your Container Registry credentials:
ACR_CREDENTIALS=$(az acr credential show --name gicampanacr) ACR_USERNAME=$(echo $ACR_CREDENTIALS | jq -r '.username') ACR_PASSWORD=$(echo $ACR_CREDENTIALS | jq -r '.passwords[0].value')
- Pass the credentials to the Web App:
az webapp config container set --name gicampan-ted-explorer \ --docker-custom-image-name gicampanacr.azurecr.io/tedapp:v1 \ --docker-registry-server-url https://gicampanacr.azurecr.io \ --docker-registry-server-user $ACR_USERNAME \ --docker-registry-server-password $ACR_PASSWORD
- Access the app at https://gicampan-ted-explorer.azurewebsites.net