public static void UploadDocuments(SearchIndexClient indexClient, string fileId, string fileName, string ocrText) { var documents = new OCRTextIndex[] { new OCRTextIndex() { fileId = fileId, fileName = fileName, ocrText = ocrText } }; try { indexClient.Documents.Index(IndexBatch.Create(documents.Select(doc => IndexAction.Create(doc)))); } catch (IndexBatchException e) { // Sometimes when your Search service is under load, indexing will fail for some of the documents in // the batch. Depending on your application, you can take compensating actions like delaying and // retrying. For this simple demo, we just log the failed document keys and continue. Console.WriteLine( "Failed to index some of the documents: {0}", String.Join(", ", e.IndexResponse.Results.Where(r => !r.Succeeded).Select(r => r.Key))); } }