你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

用于 Python 的 Azure CDN 库Azure CDN libraries for python

概述Overview

使用 Azure 内容分发网络 (CDN) 可以提供 Web 内容缓存,确保在全球范围内提供高带宽。Azure Content Delivery Network (CDN) allows you to provide web content caches to ensure high-bandwidth availability across the globe.

若要开始使用 Azure CDN,请参阅 Azure CDN 入门To get started with Azure CDN, see Getting started with Azure CDN.

管理 APIManagement APIs

使用管理 API 创建、查询和管理 Azure CDN。Create, query, and manage Azure CDNs with the management API.

通过 pip 安装管理包。Install the management package via pip.

pip install azure-mgmt-cdn

示例Example

使用定义的单个终结点创建 CDN 配置文件:Creating a CDN profile with a single defined endpoint:

from azure.mgmt.cdn import CdnManagementClient

cdn_client = CdnManagementClient(credentials, 'your-subscription-id')
profile_poller = cdn_client.profiles.create('my-resource-group',
                                            'cdn-name',
                                            {
                                                "location": "some_region", 
                                                "sku": {
                                                    "name": "sku_tier"
                                                } 
                                            })
profile = profile_poller.result()

endpoint_poller = cdn_client.endpoints.create('my-resource-group',
                                          'cdn-name',
                                          'unique-endpoint-name', 
                                          { 
                                              "location": "any_region", 
                                              "origins": [
                                                  {
                                                      "name": "origin_name", 
                                                      "host_name": "url"
                                                  }]
                                          })
endpoint = endpoint_poller.result()