Azure CDN Endpoint
This page shows how to write Terraform and Azure Resource Manager for CDN Endpoint and write them securely.
azurerm_cdn_endpoint (Terraform)
The Endpoint in CDN can be configured in Terraform with the resource name azurerm_cdn_endpoint. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_cdn_endpoint" "std_verizon_with_opt" {
name = "example"
profile_name = azurerm_cdn_profile.std_verizon.name
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
optimization_type = "DynamicSiteAcceleration"
resource "azurerm_cdn_endpoint" "cdn_endpoint_gophish" {
name = var.cdn_endpoint_name_gophish
profile_name = azurerm_cdn_profile.cdn_profile.name
location = azurerm_resource_group.azure_resource.location
resource_group_name = azurerm_resource_group.azure_resource.name
origin_host_header = var.cdn_origin_host_gophish
resource "azurerm_cdn_endpoint" "cdn_endpoint_gophish" {
name = var.cdn_endpoint_name_gophish
profile_name = azurerm_cdn_profile.cdn_profile.name
location = azurerm_resource_group.azure_resource.location
resource_group_name = azurerm_resource_group.azure_resource.name
origin_host_header = var.cdn_origin_host_gophish
resource "azurerm_cdn_endpoint" "cdn" {
for_each = var.cdn_endpoint
resource_group_name = azurerm_cdn_profile.cdn.resource_group_name
location = var.location
name = lower(join("", [each.value["endpoint_name"], random_string.cdn.result]))
profile_name = azurerm_cdn_profile.cdn.name
resource "azurerm_cdn_endpoint" "std_verizon_with_opt" {
name = "example"
profile_name = azurerm_cdn_profile.std_verizon.name
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
optimization_type = "DynamicSiteAcceleration"
resource "azurerm_cdn_endpoint" "CDN-DEV-ENDPOINT-BCP" {
name = "bcpdev"
profile_name = azurerm_cdn_profile.DEV-CDN-BCP.name
location = azurerm_resource_group.rgbcp.location
resource_group_name = azurerm_resource_group.rgbcp.name
origin_host_header = "bcpdev.z13.web.core.windows.net"
resource "azurerm_cdn_endpoint" "cdn-endpoint" {
name = "gameappcdn"
profile_name = var.cdn_profile_name
location = "westeurope"
resource_group_name = azurerm_resource_group.resource_group.name
resource "azurerm_cdn_endpoint" "example" {
name = "esgi-cdn-endpoint"
profile_name = azurerm_cdn_profile.esgi.name
location = azurerm_resource_group.RG1.location
resource_group_name = azurerm_resource_group.RG1.name
resource "azurerm_cdn_endpoint" "CdnEndpoint" {
# references: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_endpoint
name = var.cdn_endpoint_name
profile_name = var.cdn_profile_name
resource "azurerm_cdn_endpoint" "ockamio_website" {
count = length(azurerm_cdn_profile.ockam_verizon_premium)
name = var.cdn_cache_endpoint
profile_name = azurerm_cdn_profile.ockam_verizon_premium[count.index].name
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
Parameters
-
content_types_to_compressoptional computed - set of string -
host_nameoptional computed - string -
idoptional computed - string -
is_compression_enabledoptional - bool -
is_http_allowedoptional - bool -
is_https_allowedoptional - bool -
locationrequired - string -
namerequired - string -
optimization_typeoptional - string -
origin_host_headeroptional - string -
origin_pathoptional computed - string -
probe_pathoptional computed - string -
profile_namerequired - string -
querystring_caching_behaviouroptional - string -
resource_group_namerequired - string -
tagsoptional - map from string to string -
delivery_rulelist block-
namerequired - string -
orderrequired - number -
cache_expiration_actionlist block -
cache_key_query_string_actionlist block-
behaviorrequired - string -
parametersoptional - string
-
-
cookies_conditionlist block-
match_valuesoptional - set of string -
negate_conditionoptional - bool -
operatorrequired - string -
selectorrequired - string -
transformsoptional - list of string
-
-
device_conditionlist block-
match_valuesrequired - set of string -
negate_conditionoptional - bool -
operatoroptional - string
-
-
http_version_conditionlist block-
match_valuesrequired - set of string -
negate_conditionoptional - bool -
operatoroptional - string
-
-
modify_request_header_actionlist block -
modify_response_header_actionlist block -
post_arg_conditionlist block-
match_valuesoptional - set of string -
negate_conditionoptional - bool -
operatorrequired - string -
selectorrequired - string -
transformsoptional - list of string
-
-
query_string_conditionlist block-
match_valuesoptional - set of string -
negate_conditionoptional - bool -
operatorrequired - string -
transformsoptional - list of string
-
-
remote_address_conditionlist block-
match_valuesoptional - set of string -
negate_conditionoptional - bool -
operatorrequired - string
-
-
request_body_conditionlist block-
match_valuesoptional - set of string -
negate_conditionoptional - bool -
operatorrequired - string -
transformsoptional - list of string
-
-
request_header_conditionlist block-
match_valuesoptional - set of string -
negate_conditionoptional - bool -
operatorrequired - string -
selectorrequired - string -
transformsoptional - list of string
-
-
request_method_conditionlist block-
match_valuesrequired - set of string -
negate_conditionoptional - bool -
operatoroptional - string
-
-
request_scheme_conditionlist block-
match_valuesrequired - set of string -
negate_conditionoptional - bool -
operatoroptional - string
-
-
request_uri_conditionlist block-
match_valuesoptional - set of string -
negate_conditionoptional - bool -
operatorrequired - string -
transformsoptional - list of string
-
-
url_file_extension_conditionlist block-
match_valuesoptional - set of string -
negate_conditionoptional - bool -
operatorrequired - string -
transformsoptional - list of string
-
-
url_file_name_conditionlist block-
match_valuesoptional - set of string -
negate_conditionoptional - bool -
operatorrequired - string -
transformsoptional - list of string
-
-
url_path_conditionlist block-
match_valuesoptional - set of string -
negate_conditionoptional - bool -
operatorrequired - string -
transformsoptional - list of string
-
-
url_redirect_actionlist block-
fragmentoptional - string -
hostnameoptional - string -
pathoptional - string -
protocoloptional - string -
query_stringoptional - string -
redirect_typerequired - string
-
-
url_rewrite_actionlist block-
destinationrequired - string -
preserve_unmatched_pathoptional - bool -
source_patternrequired - string
-
-
-
geo_filterlist block-
actionrequired - string -
country_codesrequired - list of string -
relative_pathrequired - string
-
-
global_delivery_rulelist block-
cache_expiration_actionlist block -
cache_key_query_string_actionlist block-
behaviorrequired - string -
parametersoptional - string
-
-
modify_request_header_actionlist block -
modify_response_header_actionlist block -
url_redirect_actionlist block-
fragmentoptional - string -
hostnameoptional - string -
pathoptional - string -
protocoloptional - string -
query_stringoptional - string -
redirect_typerequired - string
-
-
url_rewrite_actionlist block-
destinationrequired - string -
preserve_unmatched_pathoptional - bool -
source_patternrequired - string
-
-
-
originset block-
host_namerequired - string -
http_portoptional - number -
https_portoptional - number -
namerequired - string
-
-
timeoutssingle block
Explanation in Terraform Registry
A CDN Endpoint is the entity within a CDN Profile containing configuration information regarding caching behaviours and origins. The CDN Endpoint is exposed using the URL format <endpointname>.azureedge.net. !> Be Aware: Azure is rolling out a breaking change on Friday 9th April which may cause issues with the CDN/FrontDoor resources. More information is available in this Github issue - however unfortunately this may necessitate a breaking change to the CDN and FrontDoor resources, more information will be posted in the Github issue as the necessary changes are identified.
Microsoft.Cdn/profiles/endpoints (Azure Resource Manager)
The profiles/endpoints in Microsoft.Cdn can be configured in Azure Resource Manager with the resource name Microsoft.Cdn/profiles/endpoints. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
"type": "Microsoft.Cdn/profiles/endpoints",
"apiVersion": "2019-12-31",
"name": "[concat(parameters('cdnName'), '/', parameters('name'))]",
"location": "Global",
"dependsOn": [
"[resourceId('Microsoft.Cdn/profiles', parameters('cdnName'))]"
"type": "Microsoft.Cdn/profiles/endpoints",
"apiVersion": "2020-04-15",
"name": "[concat(parameters('profiles_ccusfrontendcdn_name'), '/ccusfrontend')]",
"location": "Global",
"dependsOn": [
"[resourceId('Microsoft.Cdn/profiles', parameters('profiles_ccusfrontendcdn_name'))]"
Parameters
apiVersionrequired - stringlocationrequired - stringResource location.
namerequired - stringName of the endpoint under the profile which is unique globally.
propertiesrequiredcontentTypesToCompressoptional - arrayList of content types on which compression applies. The value should be a valid MIME type.
defaultOriginGroupoptionalidoptional - stringResource ID.
deliveryPolicyoptionaldescriptionoptional - stringUser-friendly description of the policy.
rulesrequired arrayactionsrequired arrayconditionsoptional arraynameoptional - stringName of the rule
orderrequired - integerThe order in which the rules are applied for the endpoint. Possible values {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. Rule with order 0 is a special rule. It does not require any condition and actions listed in it will always be applied.
geoFiltersoptional arrayactionrequired - stringAction of the geo filter, i.e. allow or block access.
countryCodesrequired - arrayTwo letter country or region codes defining user country or region access in a geo filter, e.g. AU, MX, US.
relativePathrequired - stringRelative path applicable to geo filter. (e.g. '/mypictures', '/mypicture/kitty.jpg', and etc.)
isCompressionEnabledoptional - booleanIndicates whether content compression is enabled on CDN. Default value is false. If compression is enabled, content will be served as compressed if user requests for a compressed version. Content won't be compressed on CDN when requested content is smaller than 1 byte or larger than 1 MB.
isHttpAllowedoptional - booleanIndicates whether HTTP traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed.
isHttpsAllowedoptional - booleanIndicates whether HTTPS traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed.
optimizationTypeoptional - stringSpecifies what scenario the customer wants this CDN endpoint to optimize for, e.g. Download, Media services. With this information, CDN can apply scenario driven optimization.
originGroupsoptional arraynamerequired - stringOrigin group name which must be unique within the endpoint.
propertiesoptionalhealthProbeSettingsoptionalprobeIntervalInSecondsoptional - integerThe number of seconds between health probes.Default is 240sec.
probePathoptional - stringThe path relative to the origin that is used to determine the health of the origin.
probeProtocoloptional - stringProtocol to use for health probe.
probeRequestTypeoptional - stringThe type of health probe request that is made.
originsrequired arrayidoptional - stringResource ID.
responseBasedOriginErrorDetectionSettingsoptionalhttpErrorRangesoptional arraybeginoptional - integerThe inclusive start of the http status code range.
endoptional - integerThe inclusive end of the http status code range.
responseBasedDetectedErrorTypesoptional - stringType of response errors for real user requests for which origin will be deemed unhealthy.
responseBasedFailoverThresholdPercentageoptional - integerThe percentage of failed requests in the sample where failover should trigger.
trafficRestorationTimeToHealedOrNewEndpointsInMinutesoptional - integerTime in minutes to shift the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new endpoint is added. Default is 10 mins. This property is currently not supported.
originHostHeaderoptional - stringThe host header value sent to the origin with each request. This property at Endpoint is only allowed when endpoint uses single origin and can be overridden by the same property specified at origin.If you leave this blank, the request hostname determines this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin hostname by default.
originPathoptional - stringA directory path on the origin that CDN can use to retrieve content from, e.g. contoso.cloudapp.net/originpath.
originsrequired arraynamerequired - stringOrigin name which must be unique within the endpoint.
propertiesoptionalenabledoptional - booleanOrigin is enabled for load balancing or not. By default, origin is always enabled.
hostNamerequired - stringThe address of the origin. It can be a domain name, IPv4 address, or IPv6 address. This should be unique across all origins in an endpoint.
httpPortoptional - integerThe value of the HTTP port. Must be between 1 and 65535.
httpsPortoptional - integerThe value of the HTTPS port. Must be between 1 and 65535.
originHostHeaderoptional - stringThe host header value sent to the origin with each request. If you leave this blank, the request hostname determines this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin hostname by default.
priorityoptional - integerPriority of origin in given origin group for load balancing. Higher priorities will not be used for load balancing if any lower priority origin is healthy.Must be between 1 and 5.
privateLinkAliasoptional - stringThe Alias of the Private Link resource. Populating this optional field indicates that this origin is 'Private'
privateLinkApprovalMessageoptional - stringA custom message to be included in the approval request to connect to the Private Link.
privateLinkLocationoptional - stringThe location of the Private Link resource. Required only if 'privateLinkResourceId' is populated
privateLinkResourceIdoptional - stringThe Resource Id of the Private Link resource. Populating this optional field indicates that this backend is 'Private'
weightoptional - integerWeight of the origin in given origin group for load balancing. Must be between 1 and 1000
probePathoptional - stringPath to a file hosted on the origin which helps accelerate delivery of the dynamic content and calculate the most optimal routes for the CDN. This is relative to the origin path. This property is only relevant when using a single origin.
queryStringCachingBehavioroptional - stringDefines how CDN caches requests that include query strings. You can ignore any query strings when caching, bypass caching to prevent requests that contain query strings from being cached, or cache every request with a unique URL.
urlSigningKeysoptional arraykeyIdrequired - stringDefines the customer defined key Id. This id will exist in the incoming request to indicate the key used to form the hash.
keySourceParametersrequiredresourceGroupNamerequired - stringResource group of the user's Key Vault containing the secret
secretNamerequired - stringThe name of secret in Key Vault.
secretVersionrequired - stringThe version(GUID) of secret in Key Vault.
subscriptionIdrequired - stringSubscription Id of the user's Key Vault containing the secret
typeNamerequired - stringvaultNamerequired - stringThe name of the user's Key Vault containing the secret
webApplicationFirewallPolicyLinkoptionalidoptional - stringResource ID.
tagsoptional - stringResource tags.
typerequired - string
Frequently asked questions
What is Azure CDN Endpoint?
Azure CDN Endpoint is a resource for CDN of Microsoft Azure. Settings can be wrote in Terraform.
Where can I find the example code for the Azure CDN Endpoint?
For Terraform, the gilyas/infracost, macmento/build_a_phish and ralphte/build_a_phish source code examples are useful. See the Terraform Example section for further details.
For Azure Resource Manager, the chrissheldon90/scratch and Access-America/Citizen-Center source code examples are useful. See the Azure Resource Manager Example section for further details.