locked
Enabling CORS on storage accout, error "The metrics version is null or empty." RRS feed

  • Question

  • Can someone help. As usual I try to make simple change and end up burning hours. Thanks Microsoft.

    What am I doing - Trying to set CORS on my storage account.

    Error - "The metrics version is null or empty."

    Code -

    CloudStorageAccount

    storageAccount = new CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(accountName, accountKey), true);

               

    var blobClient = storageAccount.CreateCloudBlobClient();

               

    ServiceProperties blobServiceProperties = new ServiceProperties();

                blobServiceProperties.Cors.CorsRules.Add(

    new CorsRule(){

                    AllowedHeaders =

    new List<string>() {"*"},

                    ExposedHeaders =

    new List<string>() {"*"},

                    AllowedMethods =

    CorsHttpMethods.Connect | CorsHttpMethods.Delete | CorsHttpMethods.Get

                    |

    CorsHttpMethods.Head | CorsHttpMethods.Merge | CorsHttpMethods.None | CorsHttpMethods.Options

                    |

    CorsHttpMethods.Post | CorsHttpMethods.Put | CorsHttpMethods.Trace ,

                    AllowedOrigins =

    new List<string>() {"*"},

                    MaxAgeInSeconds = 3600,

                });

                blobServiceProperties.Logging =

    new LoggingProperties(){ Version = "1.0", LoggingOperations = LoggingOperations.Write, RetentionDays = 7 };

                blobServiceProperties.HourMetrics =

    new MetricsProperties() { Version = "1.0", RetentionDays = 7, MetricsLevel = MetricsLevel.ServiceAndApi };

                blobClient.SetServiceProperties(blobServiceProperties);


    Manu

    Thursday, March 19, 2015 2:28 AM

Answers

  • This works..  Ok.. I still don't get it why Microsoft does not just give simple documentation.. :( .. Make people go crazy , rather than get their job done..

    CloudStorageAccount

    storageAccount = new CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(accountName, accountKey), true);

               

    var blobClient = storageAccount.CreateCloudBlobClient();

               

    ServiceProperties blobServiceProperties = blobClient.GetServiceProperties();//. new ServiceProperties();


                 blobServiceProperties.Cors.CorsRules.Add(

    new CorsRule(){

                    AllowedHeaders =

    new List<string>() {"*"},

                    ExposedHeaders =

    new List<string>() {"*"},

                    AllowedMethods =

    CorsHttpMethods.Connect | CorsHttpMethods.Delete | CorsHttpMethods.Get

                    |

    CorsHttpMethods.Head | CorsHttpMethods.Merge | CorsHttpMethods.None | CorsHttpMethods.Options

                    |

    CorsHttpMethods.Post | CorsHttpMethods.Put | CorsHttpMethods.Trace ,

                    AllowedOrigins =

    new List<string>() {"*"},

                    MaxAgeInSeconds = 3600,

                });


    Manu

    • Marked as answer by ManuY Thursday, March 19, 2015 2:44 AM
    Thursday, March 19, 2015 2:44 AM

All replies

  • This works..  Ok.. I still don't get it why Microsoft does not just give simple documentation.. :( .. Make people go crazy , rather than get their job done..

    CloudStorageAccount

    storageAccount = new CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(accountName, accountKey), true);

               

    var blobClient = storageAccount.CreateCloudBlobClient();

               

    ServiceProperties blobServiceProperties = blobClient.GetServiceProperties();//. new ServiceProperties();


                 blobServiceProperties.Cors.CorsRules.Add(

    new CorsRule(){

                    AllowedHeaders =

    new List<string>() {"*"},

                    ExposedHeaders =

    new List<string>() {"*"},

                    AllowedMethods =

    CorsHttpMethods.Connect | CorsHttpMethods.Delete | CorsHttpMethods.Get

                    |

    CorsHttpMethods.Head | CorsHttpMethods.Merge | CorsHttpMethods.None | CorsHttpMethods.Options

                    |

    CorsHttpMethods.Post | CorsHttpMethods.Put | CorsHttpMethods.Trace ,

                    AllowedOrigins =

    new List<string>() {"*"},

                    MaxAgeInSeconds = 3600,

                });


    Manu

    • Marked as answer by ManuY Thursday, March 19, 2015 2:44 AM
    Thursday, March 19, 2015 2:44 AM
  • If you're looking for an alternate answer or some explanation, check this out: http://stackoverflow.com/questions/25826216/endless-errors-when-trying-to-set-cors-on-azure-storage-account-blob/25826407#25826407

    Hope this helps.

    Thursday, March 19, 2015 3:37 AM