I just realized that the implementation can be applied directly using REST API or Javascript NPM package (check out the repo). So no need to use container, upload the image to container, and then upload it to blob, which less efficient.
This code is an implementation of multiple Azure AI services. Make a request to post an image, and the code will run several steps below:
- Upload the image to Azure Blob Storage
- Run the image through Azure Computer Vision to get the image description
- Translate the image description to Indonesian using Azure Translator
- Return the translated text
The whole app is deployed on Azure Instance App
-
Clone the repository
git clone https://github.com/zeerafle/image-analysis-container.git
-
Create a file named
.env
in the root directory of the project -
Create a resource group on Azure Portal
-
Create multi-service AI services on Azure Portal. Go to Keys and Endpoint, copy the Key, Endpoint, and Location/Region. Insert the values into the
.env
file with the following label:COGINITVE_SERVICE_KEY=your_key COGNITIVE_SERVICE_ENDPOINT=your_endpoint COGNITIVE_SERVICE_REGION=your_region
-
Create a storage account on Azure Portal. Go to Access keys, copy the Connection string. Insert the value into the
.env
file with the following label:STORAGE_CONNECTION_STRING=your_connection_string
-
Run the following commands to build docker image and run the container
docker build -t image-analysis-container . docker run -d -p 5000:50505 --env-file .env image-analysis-container
-
Test the app by sending a POST request to
http://localhost:5000/
with an image file
Run the following command to deploy the Docker image to Azure Container Apps.
az countainerapp up \
--resource-group your_resource_group \
--name your_container_app_name \
--ingress external \
--target-port 50505 \
--source .
If somehow it fails (like it did for me), you can push the Docker Image to Azure Container Registry and then create Azure Container Apps from the image. Remember to enable ingress and set the target port to 50505.