为azure容器创建azure cdn终结点

为azure容器创建azure cdn终结点,azure,azure-storage-blobs,azure-cdn,azure-container-service,Azure,Azure Storage Blobs,Azure Cdn,Azure Container Service,我需要为Azure容器创建Azure CDN端点。我使用下面的代码这样做 Endpoint endpoint = new Endpoint() { IsHttpAllowed = true, IsHttpsAllowed = true, Location = this.config.ResourceLocation, Origins = new List<Dee

我需要为Azure容器创建Azure CDN端点。我使用下面的代码这样做

 Endpoint endpoint = new Endpoint() {
                IsHttpAllowed = true,
                IsHttpsAllowed = true,
                Location = this.config.ResourceLocation,
                Origins = new List<DeepCreatedOrigin> { new DeepCreatedOrigin(containerName, string.Format(STORAGE_URL, storageAccountName)) },
                OriginPath = "/" + containerName,                    
            };
            await this.cdnManagementClient.Endpoints.CreateAsync(this.config.ResourceGroupName, storageAccountName, containerName, endpoint);
我提供的所有信息都是正确的,并且正在成功创建端点。但当我试图访问其中的任何blob时。它给出了一个InvalidUrl错误

然而,奇怪的是,如果我通过门户使用相同的值创建相同的端点,我就能够访问和下载blob


任何人请让我知道我在我的代码中做错了什么?我需要传递任何额外的参数吗?

据我所知,如果要在代码中创建存储CDN,需要将OriginHostHeader值设置为存储帐户URL

更多详细信息,请参考以下代码:

   // Create CDN client
            CdnManagementClient cdn = new CdnManagementClient(new TokenCredentials(token))
            { SubscriptionId = subscriptionId };
            //ListProfilesAndEndpoints(cdn);
            Endpoint e1 = new Endpoint()
            {
               // OptimizationType = "storage",
                Origins = new List<DeepCreatedOrigin>() { new DeepCreatedOrigin("{yourstoragename}-blob-core-windows-net", "{yourstoragename}.blob.core.windows.net") },
                OriginHostHeader = "{yourstoragename}.blob.core.windows.net",
                IsHttpAllowed = true,
                IsHttpsAllowed = true,
                OriginPath=@"/foo2",
                Location = "EastAsia"
        };

        cdn.Endpoints.Create(resourcegroup, profilename, enpointname, e1);

此外,我建议您可以生成令牌,通过URL直接访问blob文件。

嘿,Brando,非常感谢。似乎我的问题在传递了另一个参数OriginAuthHeader后得到了解决。我将此标记为一个答案。不过,你能帮我个忙吗?您能提供给我这些信息的来源吗?他们在创建端点时提到这个参数必须在哪里?再次感谢。很抱歉我不能给你正确的信息。我根据门户的add enpoit对话框编写此参数。它需要OriginHostHeader参数,所以我在我这边测试它。