title: Azure BlobStorage blobs to Index
body: <p>Is it possible to upload a document to a blob storage and do the following:</p>
  
  <ol>
  <li>Grab contents of document and add to index.</li>
  <li>Grab key phrases from contents in point 1 and add to index.</li>
  </ol>
  
  <p>I want the key phrases then to be searchable.</p>
  
  <p>I have code that can upload documents to a blobstorage which works perfect, but the only way to get this indexed(that I know of) is by using the "Import Data" within the Azure Search service, which creates and index with predefined fields - as below:</p>
  
  <p><a href="https://i.stack.imgur.com/CuvgH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CuvgH.png" alt="enter image description here"></a></p>
  
  <p>This works great when only needing these fields and the index gets updated automatically every 5 min. But becomes a problem when I want to have a custom Index</p>
  
  <p>However, the only fields I DO want, are the following:</p>
  
  <ul>
  <li>fileId</li>
  <li>fileText(this is the content of the document)</li>
  <li>blobURL(To allow downloading of the document)</li>
  <li>keyPhrases(Which are to be pulled from fileText - I have code that does this as well)</li>
  </ul>
  
  <p>The only issue I have is that I need to be able to retrieve the Document content(fileText) to be able to get the keyPhrases, but to my understanding, I can only do this if the Document Content is already in an index for me to access that Content? </p>
  
  <p>I have very limited knowledge with Azure and struggling to find anything that similar to what I want to do.</p>
  
  <p>The code that I am using to upload a document to my blob storage is as follows:</p>
  
  <pre><code>public CloudBlockBlob UploadBlob(HttpPostedFileBase file)
      {
          string searchServiceName = ConfigurationManager.AppSettings["SearchServiceName"];
          string blobStorageKey = ConfigurationManager.AppSettings["BlobStorageKey"];
          string blobStorageName = ConfigurationManager.AppSettings["BlobStorageName"];
          string blobStorageURL = ConfigurationManager.AppSettings["BlobStorageURL"];
          string UserID = User.Identity.GetUserId();
          string UploadDateTime = DateTime.Now.ToString("yyyyMMddhhmmss").ToString();
  
          try
          {
              var path = Path.Combine(Server.MapPath("~/App_Data/Uploads"), UserID + "_" + UploadDateTime + "_" + file.FileName);
  
              file.SaveAs(path);
  
              var credentials = new StorageCredentials(searchServiceName, blobStorageKey);
  
              var client = new CloudBlobClient(new Uri(blobStorageURL), credentials);
  
              // Retrieve a reference to a container. (You need to create one using the mangement portal, or call container.CreateIfNotExists())
              var container = client.GetContainerReference(blobStorageName);
  
              // Retrieve reference to a blob named "myfile.gif".
              var blockBlob = container.GetBlockBlobReference(UserID + "_" + UploadDateTime + "_" + file.FileName);
  
              // Create or overwrite the "myblob" blob with contents from a local file.
              using (var fileStream = System.IO.File.OpenRead(path))
              {
                  blockBlob.UploadFromStream(fileStream);
              }
  
              System.IO.File.Delete(path);
  
              return blockBlob;
          }
          catch (Exception e)
          {
              var r = e.Message;
              return null;
          }
      }
  </code></pre>
  
  <p>I hope I havnt given too much information, but I dont know how else to explain what I am looking for. If I am not making sense, please let me know so that I can fix my question.</p>
  
  <p>I am not looking for handout code, just looking for a shove in the right direction.</p>
  
  <p>I would appreciate any help.</p>
  
  <p>Thanks!</p>