Create an Azure Content Delivery Network profile and endpoint using the Azure CLI

Important

Azure CDN Standard from Microsoft (classic) will be retired on September 30, 2027. To avoid any service disruption, it is important that you migrate your Azure CDN Standard from Microsoft (classic) profiles to Azure Front Door Standard or Premium tier by September 30, 2027. For more information, see Azure CDN Standard from Microsoft (classic) retirement.

Azure CDN from Edgio will be retired on Januray 15, 2025. You must migrate your workload to Azure Front Door before this date to avoid service disruption. For more information, see Azure CDN from Edgio retirement FAQ.

As an alternative to the Azure portal, you can use these sample the Azure CLI scripts to manage the following content delivery network operations:

  • Create a content delivery network profile.
  • Create a content delivery network endpoint.
  • Create a content delivery network origin group and make it the default group.
  • Create a content delivery network origin.
  • Create a custom domain and enable HTTPS.

Prerequisites

Sample scripts

If you don't already have a resource group for your content delivery network profile, create it with the command az group create:

# Create a resource group to use for the content delivery network.
az group create --name MyResourceGroup --location eastus

The following the Azure CLI script creates a content delivery network profile and content delivery network endpoint:

# 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

The following the Azure CLI script creates a content delivery network origin group, sets the default origin group for an endpoint, and creates a new origin:

# 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

The following the Azure CLI script creates a content delivery network custom domain and enables HTTPS. Before you can associate a custom domain with an Azure content delivery network endpoint, you must first create a canonical name (CNAME) record with Azure DNS or your DNS provider to point to your content delivery network endpoint. For more information, see Create a CNAME DNS record.

# 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

Clean up resources

After you've finished running the sample scripts, use the following command to remove the resource group and all resources associated with it.

# Delete the resource group.
az group delete --name MyResourceGroup

The Azure CLI commands used in this article