適用於 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 CDNTo 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()