This repository demonstrates how to deploy applications in Azure Red Hat OpenShift (ARO) that connect to Azure Cognitive Service APIs. The first demo deploys a web application that integrates with Translate, Text Analytics, and Text-to-Speech APIs hosted by Azure. The second demo deploys a web application that integrates with a Language Detection Cognitive Service Container hosted locally inside the ARO cluster.
- Azure Red Hat OpenShift 4 Cluster
- Admin access to OpenShift
- OpenShift CLI
Follow these instructions to create a Cognitive Service in your Azure subscription.
Important: For the purposes of this demo, select the West US
region for your Cognitive Service.
Note: For the Language Detection Container demo, you must also submit a request to approve your Azure subscription for access to Cognitive Service containers. See here.
Set your key in the terminal
export COGNITIVE_SERVICE_SUBSCRIPTION_KEY=<enter-your-key>
We are going to build and deploy a Flask app based on this Microsoft Tutorial.
Build and deploy the app
oc new-app python:3.6-ubi8~https://github.com/theckang/Text-Translation-API-V3-Flask-App-Tutorial \
--name cognitive-service-demo \
--env COGNITIVE_SERVICE_SUBSCRIPTION_KEY=$COGNITIVE_SERVICE_SUBSCRIPTION_KEY
Expose the app
oc expose svc cognitive-service-demo
Open the app in your browser
echo $(oc get route cognitive-service-demo --template='http://{{.spec.host}}')
We are going to build and deploy a Language Detection application based on this Microsoft Quickstart. One container is the application frontend website. The other container is a Cognitive Service container that will detect the language of the text passed to the website. See the quickstart documentation for more information.
Clone my fork
git clone https://github.com/theckang/cognitive-services-containers-samples
Build the frontend website
oc new-build https://github.com/theckang/cognitive-services-containers-samples --context-dir dotnet/Language/FrontendService --strategy docker
Import Azure Cognitive Service Language images to the internal ARO registry
oc import-image cognitive-services-language --confirm --all --from mcr.microsoft.com/azure-cognitive-services/textanalytics/language
Allow resources to reference the image streams
oc set image-lookup cognitive-services-containers-samples
oc set image-lookup cognitive-services-language
Open the cognitive-services-containers-samples/Kubernetes/language/language.yml
file in your favorite editor and insert your subscription key for the apikey
field.
You can view your subscription key with the command below
echo $COGNITIVE_SERVICE_SUBSCRIPTION_KEY
Deploy the containers
oc create -f cognitive-services-containers-samples/Kubernetes/language/language.yml