重要
Azure CDN Standard from Microsoft (クラシック) は 、2027 年 9 月 30 日に廃止されます。 サービスの中断を回避するには、2027 年 9 月 30 日までに Azure CDN Standard を Microsoft (クラシック) プロファイルから Azure Front Door Standard または Premium レベルに移行することが重要です。 詳細については、 Azure CDN Standard from Microsoft (クラシック) の提供終了に関するページを参照してください。
Edgio からの Azure CDN は 、2025 年 1 月 15 日に廃止されました。 詳細については、 Azure CDN from Edgio の提供終了に関する FAQ を参照してください。
Azure portal の代わりに、次のサンプル Azure CLI スクリプトを使用して、次のコンテンツ配信ネットワーク操作を管理できます。
- コンテンツ配信ネットワークのプロファイルを作成します。
- コンテンツ配信ネットワークのエンドポイントを作成します。
- コンテンツ配信ネットワークの配信元グループを作成し、それを既定のグループにします。
- コンテンツ配信ネットワークの配信元を作成します。
- カスタム ドメインを作成し、HTTPS を有効にする。
前提条件
Azure Cloud Shell で Bash 環境を使用します。 詳細については、「 Azure Cloud Shell の概要」を参照してください。
CLI 参照コマンドをローカルで実行する場合は、Azure CLI を インストール します。 Windows または macOS で実行している場合は、Docker コンテナーで Azure CLI を実行することを検討してください。 詳細については、「 Docker コンテナーで Azure CLI を実行する方法」を参照してください。
ローカル インストールを使用している場合は、 az login コマンドを使用して Azure CLI にサインインします。 認証プロセスを完了するには、ターミナルに表示される手順に従います。 その他のサインイン オプションについては、「 Azure CLI を使用した Azure への認証」を参照してください。
初回使用時にインストールを求められたら、Azure CLI 拡張機能をインストールします。 拡張機能の詳細については、「 Azure CLI での拡張機能の使用と管理」を参照してください。
az version を実行して、インストールされているバージョンと依存ライブラリを見つけます。 最新バージョンにアップグレードするには、 az upgrade を実行します。
サンプルのスクリプト
コンテンツ配信ネットワーク プロファイルのリソース グループがまだない場合は、コマンド az group create を実行してこれを作成します。
# Create a resource group to use for the content delivery network.
az group create --name MyResourceGroup --location eastus
次の Azure CLI スクリプトでは、コンテンツ配信ネットワーク プロファイルとコンテンツ配信ネットワーク エンドポイントが作成されます。
# Create a content delivery network profile.
az cdn profile create --resource-group MyResourceGroup --name MyCDNProfile --sku Standard_Microsoft
# Create a content delivery network endpoint.
az cdn endpoint create --resource-group MyResourceGroup --name MyCDNEndpoint --profile-name MyCDNProfile --origin www.contoso.com
次の Azure CLI スクリプトでは、コンテンツ配信ネットワークの配信元グループが作成され、エンドポイントの既定の配信元グループが設定され、新しい配信元が作成されます。
# Create an origin group.
az cdn origin-group create --resource-group MyResourceGroup --endpoint-name MyCDNEndpoint --profile-name MyCDNProfile --name MyOriginGroup --origins origin-0
# Make the origin group the default group of an endpoint.
az cdn endpoint update --resource-group MyResourceGroup --name MyCDNEndpoint --profile-name MyCDNProfile --default-origin-group MyOriginGroup
# Create another origin for an endpoint.
az cdn origin create --resource-group MyResourceGroup --endpoint-name MyCDNEndpoint --profile-name MyCDNProfile --name origin-1 --host-name example.contoso.com
次の Azure CLI スクリプトでは、コンテンツ配信ネットワーク カスタム ドメインが作成され、HTTPS が有効になります。 カスタム ドメインを Azure Content Delivery Network エンドポイントに関連付けるためには、最初にコンテンツ配信ネットワーク エンドポイントを指す正規名 (CNAME) レコードを Azure DNS またはご利用の DNS プロバイダーで作成する必要があります。 詳細については、「 CNAME DNS レコードの作成」を参照してください。
# Associate a custom domain with an endpoint.
az cdn custom-domain create --resource-group MyResourceGroup --endpoint-name MyCDNEndpoint --profile-name MyCDNProfile --name MyCustomDomain --hostname www.example.com
# Enable HTTPS on the custom domain.
az cdn custom-domain enable-https --resource-group MyResourceGroup --endpoint-name MyCDNEndpoint --profile-name MyCDNProfile --name MyCustomDomain
リソースをクリーンアップする
サンプル スクリプトの実行が完了したら、次のコマンドを使用して、リソース グループとそれに関連付けられているすべてのリソースを削除します。
# Delete the resource group.
az group delete --name MyResourceGroup
この記事で使用されている Azure CLI コマンド
- コマンド「az cdn endpoint create」(新しい CDN エンドポイントを作成する)
- az cdn エンドポイント更新
- az cdn origin create(CDNオリジンの作成コマンド)
- az cdn origin-group create
- az cdn profile create コマンド
- az group create コマンドを使用して Azure のグループを作成します。
- az group delete コマンドは、Azure グループを削除します。
- az cdn custom-domain create
- az cdn custom-domain enable-HTTPS コマンドは、カスタムドメインのHTTPSを有効にします。