title: Cors Error on Microsoft Azure Cloud Storage
body: <p>Hello I am having a Cors Error on Microsoft Azure Cloud Storage.</p>
  
  <p>I am generating my SAS as follows:</p>
  
  <pre><code>public SAS(string containername, string id, SharedAccessBlobPermissions permissions)
  {
      this.id = id;
      CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
      CloudBlobContainer containerReference = cloudStorageAccount.CreateCloudBlobClient().GetContainerReference("teeessssttt");
      if (containerReference.CreateIfNotExists(null, null))
      {
          BlobConfig.configureCORS();
      }
      CloudBlockBlob blockBlobReference = containerReference.GetBlockBlobReference(id);
      SharedAccessBlobPolicy sharedAccessBlobPolicy = new SharedAccessBlobPolicy()
      {
          Permissions = permissions
      };
      DateTime utcNow = DateTime.UtcNow;
      sharedAccessBlobPolicy.SharedAccessStartTime = new DateTimeOffset?(utcNow.AddMinutes(-5));
      DateTime dateTime = DateTime.UtcNow;
      sharedAccessBlobPolicy.SharedAccessExpiryTime = new DateTimeOffset?(dateTime.AddMinutes(15));
      string sharedAccessSignature = blockBlobReference.GetSharedAccessSignature(sharedAccessBlobPolicy);
      this.HostingSite = blockBlobReference.Uri.AbsoluteUri;
      this.Token = sharedAccessSignature;
      this.fullurl = string.Concat(this.HostingSite, this.Token);
  }
  </code></pre>
  
  <p>This generates something like:</p>
  
  <pre><code>{"fullurl":"https://ingenovatebeta.blob.core.windows.net/teeessssttt/7554eb72-f361-4715-a255-a5d6922706b0?sv=2013-08-15&amp;sr=b&amp;sig=iVL4zeytgC1H7W09lV2YZspOKlzF433oqsx9I6cfI68%3D&amp;st=2014-10-24T05%3A58%3A13Z&amp;se=2014-10-24T06%3A18%3A13Z&amp;sp=w","HostingSite":"https://ingenovatebeta.blob.core.windows.net/teeessssttt/7554eb72-f361-4715-a255-a5d6922706b0","id":"7554eb72-f361-4715-a255-a5d6922706b0","Token":"?sv=2013-08-15&amp;sr=b&amp;sig=iVL4zeytgC1H7W09lV2YZspOKlzF433oqsx9I6cfI68%3D&amp;st=2014-10-24T05%3A58%3A13Z&amp;se=2014-10-24T06%3A18%3A13Z&amp;sp=w"}
  </code></pre>
  
  <p>I am setting up my cors as follows:</p>
  
  <pre><code>CorsRule corsRule = new CorsRule();
  corsRule.AllowedOrigins.Add("https://---------------.com");
  corsRule.AllowedMethods = CorsHttpMethods.Get | CorsHttpMethods.Post | CorsHttpMethods.Put |           
  CorsHttpMethods.Options;
  corsRule.AllowedHeaders.Add("*");
  corsRule.ExposedHeaders.Add("*");
  corsRule.MaxAgeInSeconds = (int)TimeSpan.FromDays(5).TotalSeconds;
  corsRules.Add(corsRule);
  serviceProperty.Cors = corsProperty;
  </code></pre>
  
  <p>This works when I upload files just to the GUID.  For example setting my upload URI like the following works:</p>
  
  <pre><code>$.get("/api/sas", (function (json) {    
      var baseUrl = json.fullurl;                                  
      myDropzone.options.url = baseUrl;
      myDropzone.processFile(file);
  }));
  </code></pre>
  
  <p>However all my files end up in my cloud storage as just the GUID's and no file names or extensions this makes it hard to retrieve the images and such.  In the examples the show you can add a filename.  I have followed the examples:</p>
  
  <pre><code>$.get("/api/sas", (function (json) {
  
      var baseUrl = json.fullurl;
      var indexOfQueryStart = baseUrl.indexOf("?");
      submitUri = baseUrl.substring(0, indexOfQueryStart) + '/' + file.name + baseUrl.substring(indexOfQueryStart);
  
      myDropzone.options.url = submitUri;
      myDropzone.processFile(file);
   }));
  </code></pre>
  
  <p>However it does not work.  At this point I get a CORS error:</p>
  
  <pre><code>XMLHttpRequest cannot load https://myurl/mycontainer/82b7f14b-ee7c-45a3…2B%2BmtAJw%3D&amp;st=2014-10-23T04%3A34%3A22Z&amp;se=2014-10-23T04%3A54%3A22Z&amp;sp=w. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://stagingrapidrealities.azurewebsites.net' is therefore not allowed access. The response had HTTP status code 403. ​
  </code></pre>