public void UploadBlob(string containerName, string blobName, string contentType, Stream content) { if (!blobsPerContainer.ContainsKey(containerName)) { throw new ApplicationException($"Container {containerName} does not exist"); } var blobList = blobsPerContainer[containerName]; BlobInfoModel blob = new BlobInfoModel() { Name = blobName, CreatedOn = DateTime.Now, Size = content.Length, ContentType = contentType }; blobList.Add(blob); }
public static async Task ValidateOCRAppStart([BlobTrigger("ocrinfoblob/{name}")] CloudBlockBlob cloudBlockBlob, [Blob("ocrinfoblob/{name}", FileAccess.ReadWrite)] byte[] blobContents, [DurableClient] IDurableOrchestrationClient starter, ILogger logger) { var blobInfoModel = new BlobInfoModel() { ImageName = cloudBlockBlob.Name, BlobContents = blobContents }; string instanceId = await starter.StartNewAsync("ProcessBlobContents", blobInfoModel); logger.LogInformation($"Started orchestration with ID = '{instanceId}'."); }
public static async Task <string> ParseOCRAsync([ActivityTrigger] BlobInfoModel blobInfoModel, ILogger logger) { var client = new HttpClient(); var apiKeyString = Environment.GetEnvironmentVariable("OCR_API_KEY"); client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", apiKeyString); var content = new ByteArrayContent(blobInfoModel?.BlobContents); content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); var ocrResponse = await client.PostAsync(Environment.GetEnvironmentVariable("OCR_URL"), content); var parsedOCR = await ocrResponse.Content.ReadAsStringAsync(); logger.LogInformation($"OCR = {parsedOCR}"); return(parsedOCR); }