Skip to content

srnagar/azsdkdemo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure SDK Demo - Azure Image Analyzer

The repo demonstrates Azure SDK usage via a complete application. This application takes in an image, uploads it to Blog Storage and enqueues a message into a Queue. A process receives that message and uses Form Recognizer to extract the text from the image, then uses Text Analytics to get the sentiment of the text, and then stores the results in a Cosmos DB.

Pre-reqs

The following are required to run this application.

  1. A Terminal - We tested this with Git Bash and WSL - it will not currently work with PowerShell or Windows Command Prompt. The Terraform deployment currently only works on Linux compatible systems. You will need to run all the commands below in your selected terminal.
  2. Install Azure CLI
  3. Install Terraform
  4. Install Git
  5. Install VS Code
  6. Install Docker
  7. An Azure Subscription

Azure Resources

The following Azure resources will be deployed with the Terraform script.

  1. Resource Group
  2. Storage Account
  3. Cognitive Services Form Recognizer
  4. Cognitive Services Text Analytics
  5. Cosmos DB
  6. Key Vault
  7. Azure Kubernetes Service
  8. Application Insights

Code Setup

  1. Open Git Bash or WSL - The same terminal you used to install the pre-reqs above.
  2. Clone Repo git clone https://github.com/jongio/azsdkdemo
  3. Azure CLI Login az login
  4. Create Azure Resources with Terraform
    1. CD to iac/terraform
    2. Terraform init: terraform init
    3. Terraform plan: terraform plan -var="basename=azsdkdemo1" --out tf.plan

      Change the basename variable from azsdkdemo1 to something that will be globally unique. It will be used as part of Azure resource names, so keep it short, lowercase, and no special characters.

    4. Terraform apply: terraform apply tf.plan
  5. Update .env file
    1. Copy and paste the Terraform output values to the .env file in the root of this repo.

      NOTE: .env files do not allow spaces around the =, so please remove any spaces after you copy and paste.

Run Application

Docker Compose

  1. CD to the src folder for the language you would like to run, i.e. for .NET, cd to src/net for Python, cd to src/python
  2. Run docker-compose up --build
  3. Navigate to http://localhost:1080
  4. Add an Image
    1. Enter url into text box and click "Submit"
    2. Or click "Add Random Meme"
    3. The image will be added to the grid. Wait for the service to pick it up. You will eventually see the text and the image border color will change indicating the image text sentiment.

Local Kubernetes

  1. Copy the values outputted from the Terraform commands above (they should be in your .env file if you followed the Code Setup steps above) into the pac/net/k8s/local/env-configmap.yaml file.
  2. CD to the src folder for the language you would like to run, i.e. for .NET, cd to src/net for Python, cd to src/python.
  3. Run docker-compose build to build the containers locally.
  4. CD to pac/net/k8s/local.
  5. Run ./mount.sh to mount your local .azure folder to the container, so we can use AzureCliCredential in Kubernetes.
  6. Run kubectl apply -f .
  7. Navigate to http://localhost:31389

Azure Kubernetes Service

  1. Copy the values outputted from the Terraform commands above (they should be in your .env file if you followed the Code Setup steps above) into the pac/net/k8s/aks/env-configmap.yaml file.
  2. Run the az aks get-credentials command that was outputted from the terraform apply command you ran earlier. It is something like az aks get-credentials --resource-group azsdkdemo100rg --name azsdkdemo100aks. Replace the resource group and cluster name with the one you created with Terraform earlier.
  3. Install Helm - This will be used for an nginx ingress controller that will expose a Public IP for our cluster and handle routing.
  4. Run the following commands:
    helm repo add stable https://kubernetes-charts.storage.googleapis.com/
    helm install nginx stable/nginx-ingress
    
  5. CD to the src folder for the language you would like to run, i.e. for .NET, cd to src/net for Python, cd to src/python.
  6. Login to your container registry. docker login or az acr login.
  7. Search the entire project for image names that start with jongio/ and replace with the name of your container registry.

    Note: This experience will be improved with Helm or Kustomize soon.

  8. Run docker-compose push to push the containers to your container registry of choice.
  9. Run az network public-ip list -g azsdkdemo100aksnodes --query '[0].ipAddress' --output tsv to find the AKS cluster's public IP address.

    Note: Change the resource group to your node_resource_group name, this command is also outputted by the Terraform commands.

  10. Open /pac/net/k8s/aks/web-configmap.yaml and change the API_ENDPOINT value to the Public IP address.
  11. CD to /pac/net/k8s/aks and run kubectl apply -f .
  12. Open a browser and go to that Public IP.

About

Let's demo the new Azure SDKs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 32.5%
  • Java 29.5%
  • HCL 14.4%
  • HTML 9.6%
  • Python 4.9%
  • CSS 4.5%
  • Other 4.6%