Quickstart: Create an Azure CDN profile and endpoint - ARM template

Get started with Azure Content Delivery Network (CDN) by using an Azure Resource Manager template (ARM template). The template deploys a profile and an endpoint.

An ARM template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. In declarative syntax, you describe your intended deployment without writing the sequence of programming commands to create the deployment.

If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template will open in the Azure portal.

Deploy to Azure

Prerequisites

If you don't have an Azure subscription, create a free account before you begin.

Review the template

The template used in this quickstart is from Azure Quickstart Templates.

This template is configured to create a:

  • Profile
  • Endpoint
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "profileName": {
      "type": "string",
      "defaultValue": "myCDNProfile",
      "metadata": {
        "description": "Name of the CDN Profile"
      }
    },
    "endpointName": {
      "type": "string",
      "metadata": {
        "description": "Name of the CDN Endpoint, must be unique"
      }
    },
    "originUrl": {
      "type": "string",
      "metadata": {
        "description": "Url of the origin"
      }
    },
    "CDNSku": {
      "type": "string",
      "metadata": {
        "description": "CDN SKU names"
      },
      "defaultValue": "Standard_Microsoft",
      "allowedValues": [
        "Standard_Akamai",
        "Standard_Microsoft",
        "Standard_Verizon",
        "Premium_Verizon"
      ]
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.Cdn/profiles",
      "apiVersion": "2020-04-15",
      "name": "[parameters('profileName')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "[parameters('CDNSku')]"
      },
      "resources": [
        {
          "type": "endpoints",
          "apiVersion": "2020-04-15",
          "name": "[parameters('endpointName')]",
          "location": "[parameters('location')]",
          "dependsOn": [
            "[resourceId('Microsoft.Cdn/profiles', parameters('profileName'))]"
          ],
          "properties": {
            "originHostHeader": "[parameters('originUrl')]",
            "isHttpAllowed": true,
            "isHttpsAllowed": true,
            "queryStringCachingBehavior": "IgnoreQueryString",
            "contentTypesToCompress": [
              "application/eot",
              "application/font",
              "application/font-sfnt",
              "application/javascript",
              "application/json",
              "application/opentype",
              "application/otf",
              "application/pkcs7-mime",
              "application/truetype",
              "application/ttf",
              "application/vnd.ms-fontobject",
              "application/xhtml+xml",
              "application/xml",
              "application/xml+rss",
              "application/x-font-opentype",
              "application/x-font-truetype",
              "application/x-font-ttf",
              "application/x-httpd-cgi",
              "application/x-javascript",
              "application/x-mpegurl",
              "application/x-opentype",
              "application/x-otf",
              "application/x-perl",
              "application/x-ttf",
              "font/eot",
              "font/ttf",
              "font/otf",
              "font/opentype",
              "image/svg+xml",
              "text/css",
              "text/csv",
              "text/html",
              "text/javascript",
              "text/js",
              "text/plain",
              "text/richtext",
              "text/tab-separated-values",
              "text/xml",
              "text/x-script",
              "text/x-component",
              "text/x-java-source"
            ],
            "isCompressionEnabled": true,
            "origins": [
              {
                "name": "origin1",
                "properties": {
                  "hostName": "[parameters('originUrl')]"
                }
              }
            ]
          }
        }
      ]
    }
  ]
}

One Azure resource is defined in the template:

Deploy the template

Azure CLI

read -p "Enter the location (i.e. eastus): " location
resourceGroupName="myResourceGroupCDN"
templateUri="https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.cdn/cdn-with-custom-origin/azuredeploy.json"

az group create \
--name $resourceGroupName \
--location $location

az deployment group create \
--resource-group $resourceGroupName \
--template-uri  $templateUri

PowerShell

$location = Read-Host -Prompt "Enter the location (i.e. eastus)"
$templateUri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.cdn/cdn-with-custom-origin/azuredeploy.json"

$resourceGroupName = "myResourceGroupCDN"

New-AzResourceGroup -Name $resourceGroupName -Location $location
New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri

Portal

Deploy to Azure

Review deployed resources

  1. Sign in to the Azure portal.

  2. Select Resource groups from the left pane.

  3. Select the resource group that you created in the previous section. The default resource group name is myResourceGroupCDN

  4. Verify the following resources were created in the resource group:

    Azure CDN resource group

Clean up resources

Azure CLI

When no longer needed, you can use the az group delete command to remove the resource group and all resources contained within.

  az group delete \
    --name myResourceGroupCDN

PowerShell

When no longer needed, you can use the Remove-AzResourceGroup command to remove the resource group and all resources contained within.

Remove-AzResourceGroup -Name myResourceGroupCDN

Portal

When no longer needed, delete the resource group, CDN profile, and all related resources. Select the resource group myResourceGroupCDN that contains the CDN profile and endpoint, and then select Delete.

Next steps

In this quickstart, you created a:

  • CDN Profile
  • Endpoint

To learn more about Azure CDN and Azure Resource Manager, continue to the articles below.