title: Import data into SQL Server from an Azure Excel blob file
body: <p>I have an MVC web application that allows user to upload an Excel files to Azure cloud storage, and then the application uses that Azure-stored Excel blob file to import data into SQL Server.</p>
  
  <p>I follow the sites 
  <a href="http://www.codeproject.com/Tips/752981/Import-Data-from-Excel-File-to-Database-Table-in-A" rel="nofollow noreferrer">http://www.codeproject.com/Tips/752981/Import-Data-from-Excel-File-to-Database-Table-in-A</a></p>
  
  <p>and</p>
  
  <p><a href="https://stackoverflow.com/questions/11228292/upload-excel-file-and-extract-data-from-it-and-put-that-data-in-database-using-m">Upload Excel File and Extract Data from it and put that data in database using MVC asp.net</a></p>
  
  <p>to do my application.  However, the example from the site <a href="http://www.codeproject.com/Tips/752981/Import-Data-from-Excel-File-to-Database-Table-in-A" rel="nofollow noreferrer">http://www.codeproject.com/Tips/752981/Import-Data-from-Excel-File-to-Database-Table-in-A</a>  lets users upload file to <strong>web server where application is deployed not Azure storage</strong>, and the contents of "fileLocation" variable (please see the below codes) looks like (relative to web-server-hosted application path C or whatever drive) <strong>"C:\MyWebApplicationFolder\MyApplicatioName\Content\Excel_blob.xlsx"</strong></p>
  
  <p><strong>My question</strong>: for Azure storage Excel blob files, how can I specify the value of "fileLocation" and "excelConnectionString" variables?  Please see my code comments starting with phrase "// *** How can I can do this with Azure storage codes?" below.</p>
  
  <p>Codes from <a href="http://www.codeproject.com/Tips/752981/Import-Data-from-Excel-File-to-Database-Table-in-A" rel="nofollow noreferrer">http://www.codeproject.com/Tips/752981/Import-Data-from-Excel-File-to-Database-Table-in-A</a></p>
  
  <pre><code>[HttpPost]
  public ActionResult Upload(HttpPostedFileBase file)
  {
      DataSet ds = new DataSet();
      if (Request.Files["file"].ContentLength &gt; 0)
      {
          string fileExtension =  System.IO.Path.GetExtension(Request.Files["file"].FileName);
  
          if (fileExtension == ".xls" || fileExtension == ".xlsx")
          {
              string fileLocation = Server.MapPath("~/Content/") + Request.Files["file"].FileName;  // *** How can I can do this with Azure storage codes?
  
          if (System.IO.File.Exists(fileLocation))
          {
              System.IO.File.Delete(fileLocation);
          }
          Request.Files["file"].SaveAs(fileLocation);
          string excelConnectionString = string.Empty;
  
          excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +     fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";  // *** How can I can do this with Azure storage codes?
  
  
          //connection String for xls file format.
          if (fileExtension == ".xls")
          {
              excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +   fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";     // *** How can I can do this with Azure storage codes?
          }
          //connection String for xlsx file format.
          else if (fileExtension == ".xlsx")
          {
              excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +   fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";     // *** How can I can do this with Azure storage codes?
          }  
  
          ...  
  </code></pre>