Skip to content

Instantly share code, notes, and snippets.

@kennetham
Created May 5, 2018 05:27
Show Gist options
  • Save kennetham/648c9c00f4399db9837cf96e56dca984 to your computer and use it in GitHub Desktop.
Save kennetham/648c9c00f4399db9837cf96e56dca984 to your computer and use it in GitHub Desktop.
PNG OCR Logic App
{
"$connections": {
"value": {
"azureblob": {
"connectionId": "/subscriptions/<subscription_id>/resourceGroups/msdemo-sea-rg/providers/Microsoft.Web/connections/azureblob",
"connectionName": "azureblob",
"id": "/subscriptions/<subscription_id>/providers/Microsoft.Web/locations/southeastasia/managedApis/azureblob"
},
"cognitiveservicescomputervision": {
"connectionId": "/subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/Microsoft.Web/connections/cognitiveservicescomputervision",
"connectionName": "cognitiveservicescomputervision",
"id": "/subscriptions/<subscription_id>/providers/Microsoft.Web/locations/southeastasia/managedApis/cognitiveservicescomputervision"
}
}
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "@{body('Optical_Character_Recognition_(OCR)_to_Text')}@{body('Optical_Character_Recognition_(OCR)_to_Text')?['text']}",
"runAfter": {
"Optical_Character_Recognition_(OCR)_to_Text": [
"Succeeded"
]
},
"type": "Compose"
},
"Compose_2": {
"inputs": "@body('Optical_Character_Recognition_(OCR)_to_JSON_2')",
"runAfter": {
"Optical_Character_Recognition_(OCR)_to_JSON_2": [
"Succeeded"
]
},
"type": "Compose"
},
"Create_block_blob": {
"inputs": {
"body": "@outputs('Compose_2')",
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "post",
"path": "/codeless/CreateBlockBlob",
"queries": {
"folderPath": "/ocr-results",
"name": "@{triggerBody()?['blob_name']}.json"
}
},
"runAfter": {
"Compose_2": [
"Succeeded"
]
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
},
"type": "ApiConnection"
},
"Create_block_blob_2": {
"inputs": {
"body": "@outputs('Compose')",
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "post",
"path": "/codeless/CreateBlockBlob",
"queries": {
"folderPath": "/ocr-results",
"name": "@{triggerBody()?['blob_name']}.txt"
}
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
},
"type": "ApiConnection"
},
"Optical_Character_Recognition_(OCR)_to_JSON_2": {
"inputs": {
"body": {
"url": "https://<storage_name>.blob.core.windows.net/output/@{triggerBody()?['blob_name']}"
},
"host": {
"connection": {
"name": "@parameters('$connections')['cognitiveservicescomputervision']['connectionId']"
}
},
"method": "post",
"path": "/vision/v1.0/ocr",
"queries": {
"detectOrientation": true,
"format": "Image URL",
"language": "en"
}
},
"runAfter": {},
"type": "ApiConnection"
},
"Optical_Character_Recognition_(OCR)_to_Text": {
"inputs": {
"body": {
"url": "https://<storage_name>.blob.core.windows.net/output/@{triggerBody()?['blob_name']}"
},
"host": {
"connection": {
"name": "@parameters('$connections')['cognitiveservicescomputervision']['connectionId']"
}
},
"method": "post",
"path": "/vision/v1.0/ocrtext",
"queries": {
"detectOrientation": true,
"format": "Image URL",
"language": "en"
}
},
"runAfter": {},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"manual": {
"inputs": {
"schema": {
"properties": {
"blob_name": {
"type": "string"
}
},
"type": "object"
}
},
"kind": "Http",
"type": "Request"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment