Skip to content

grohmio/azure_terraform_ocr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

azure_terraform_ocr

purpose

  • simple example doing OCR using Azure Function Apps, Cognitive Services Blob Storage in combination with terraform

initial setup project from scratch

  • prerequisits azure-cli, azure subscription
  • fork this repo

create Service Principal

  • azure-cli login
az login
  • list subscriptions
az account list
  • set correct subscription
az account set --subscription="...<SUBSCRIPTION_ID>..."
  • create service account
az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/...<SUBSCRIPTION_ID>..."

{
"appId": "...",
"displayName": "...",
"name": "...",
"password": "...",
"tenant": "..."
}
  • remember these mappings
ARM_CLIENT_ID = appId
ARM_CLIENT_SECRET = password
ARM_TENANT_ID = tenant
ARM_SUBSCRIPTION_ID can be found in the `Azure Portal` or in the `Service Principal` account `id`
  • login as Service Principal
az login --service-principal -u <client-id> -p <client-secret> --tenant <tenant-id>
  • set values in github>>settings>>secrets
ARM_CLIENT_ID="..."
ARM_CLIENT_SECRET="..."
ARM_SUBSCRIPTION_ID="..."
ARM_TENANT_ID="..."

manual setup

  • you need terraform installed
  • follow [setup terraform tfstate in azure](##setup terraform tfstate in azure)
  • login as Service Principal
az login --service-principal -u <client-id> -p <client-secret> --tenant <tenant-id>
  • init project
terraform init -reconfigure
  • plan, execute following command and enter credentials
terraform plan -out "planfile"
  • apply
terraform apply -input=false "planfile"

setup terraform tfstate in azure

  • generate resource group azure-terraform-ocr-tfstate in azure console
  • generate storage account tfstatestoraccXYZ in azure console, this is a custom value and need to be globaly unique in azure, remember the key under menu Access keys, deactivate Enable blob public access, chose LRS
  • generate storage container tfstatestorcon in azure console
  • set values in github>>settings>>secrets>>actions
AZDO_PERSONAL_ACCESS_TOKEN=...key...
TFSTATE_STORAGE_ACCOUNT_NAME=tfstatestoraccXYZ
TF_VAR_CUSTOMIZERE=...<custom and unique code for url's, e.g. '0815'>...

set up azure function

  • select function folder
cd azure_functions
  • install function build tools
npm install -g azure-functions-core-tools@3 --unsafe-perm true

or

brew tap azure/functions
brew install azure-functions-core-tools@3
  • initialize function project
func init
  • start function locally
func start
  • deploy function
npm ci
func azure functionapp publish azure-terraform-ocr-node-functions

setup pipeline

TODO

further reads

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •