试图设置Azure存储帐户/斑点CORS当无尽的错误 [英] Endless Errors when trying to set cors on azure storage account / Blob

查看:142
本文介绍了试图设置Azure存储帐户/斑点CORS当无尽的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立CORS上Azure存储BLOB帐户,我添加了一个CDN来。
原因是这样我可以为来自那里的网页字体,并获得高速缓存。

I am trying to set up cors on an azure storage blob account, that I have added a CDN to. the reason is so that I can serve the web fonts from there and get the caching.

我从安装的NuGet最新的软件:

I have installed latest software from nuget:

成功添加Microsoft.Data.Services.Client 5.6.0来的冲动。
添加Microsoft.WindowsAzure.ConfigurationManager 1.8.0.0来的冲动。
已成功添加Microsoft.WindowsAzure.ConfigurationManager 1.8.0.0来的冲动。
添加WindowsAzure.Storage 4.2.1来的冲动。
已成功添加WindowsAzure.Storage 4.2.1提供的脉冲。

Successfully added 'Microsoft.Data.Services.Client 5.6.0' to Impulse. Adding 'Microsoft.WindowsAzure.ConfigurationManager 1.8.0.0' to Impulse. Successfully added 'Microsoft.WindowsAzure.ConfigurationManager 1.8.0.0' to Impulse. Adding 'WindowsAzure.Storage 4.2.1' to Impulse. Successfully added 'WindowsAzure.Storage 4.2.1' to Impulse.

我已经然后用这个C#code:

I have then used this C# code :

private void AzureCors()
        {
            CloudStorageAccount storageAccount = new CloudStorageAccount(new StorageCredentials("removed","removed"), true);
            var blobClient = storageAccount.CreateCloudBlobClient();
            ServiceProperties blobServiceProperties = new ServiceProperties();
            blobServiceProperties.Cors.CorsRules.Add(new CorsRule(){
                AllowedHeaders = new List<string>() { "*" },
                AllowedMethods = CorsHttpMethods.Put | CorsHttpMethods.Get | CorsHttpMethods.Head | CorsHttpMethods.Post,
                AllowedOrigins = new List<string>() { "*" },
                ExposedHeaders = new List<string>() { "*" },
                MaxAgeInSeconds = 3600 // 30 minutes 
            });

            blobClient.SetServiceProperties(blobServiceProperties);
        }

这第一个错误是日志版本空。然而,根据该MS不再是必需的,但我加了也无妨。然后,我得到一个错误的衡量标准版本为空或空的,但是这也是不应该是必需的,但不仅如此,但实际上是从4.2.1停产,我无法反正设定的指标,而code到现在用的就是HourMetrics,然而,在一个小时指标仍填充给出了一个错误的度量。

This first error is The logging version is null or empty. however this according to MS is no longer required, but I added it anyway. Then I get an error that the Metrics Version is null or empty, however this too is not supposed to be required, but not only that, but is actually discontinued from 4.2.1 and I am unable to set metrics anyway, and the code to now use is HourMetrics, however, filling in an hour metrics still gives an error for metrics.

那么到底是怎么回事,到底是多么我应该连接到Azure存储,如果没有了图书馆的实际工作?

So what is going on, how the hell am I supposed to connect to azure storage, if none off the libraries actually work?

不知道这可能是一个问题?

not sure if this could be an issue?

推荐答案

试试这个code:

    private void AzureCors()
    {
        CloudStorageAccount storageAccount = new CloudStorageAccount(new StorageCredentials("removed", "removed"), true);
        var blobClient = storageAccount.CreateCloudBlobClient();
        ServiceProperties blobServiceProperties = new ServiceProperties()
        {
            HourMetrics = null,
            MinuteMetrics = null,
            Logging = null,
        };
        blobServiceProperties.Cors.CorsRules.Add(new CorsRule()
        {
            AllowedHeaders = new List<string>() { "*" },
            AllowedMethods = CorsHttpMethods.Put | CorsHttpMethods.Get | CorsHttpMethods.Head | CorsHttpMethods.Post,
            AllowedOrigins = new List<string>() { "*" },
            ExposedHeaders = new List<string>() { "*" },
            MaxAgeInSeconds = 3600 // 30 minutes 
        });

        blobClient.SetServiceProperties(blobServiceProperties);
    }

基本上当你创建 ServiceProperties 的一个实例,如 HourMetrics 等所有属性得到初始化。你需要做的是强制设置的属性是什么,你不想更改为,这就是我在构造函数中一样。

Basically when you create an instance of ServiceProperties, all properties like HourMetrics etc. get initialized. What you need to do is forcefully set the properties you don't want to change to null and this is what I did in the constructor.

这篇关于试图设置Azure存储帐户/斑点CORS当无尽的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆