CDN

Overview

The CDN builder is used to create Azure Content Delivery Network instances.

  • CDN Profile (Microsoft.Cdn/profiles)
  • CDN Endpoint (Microsoft.Cdn/profiles/endpoints)
  • CDN Custom Domain (Microsoft.Cdn/profiles/endpoints/customDomains)

There are three builders available:

  • The CDN builder, which maps to a CDN profile.
  • The Endpoint builder, which creates endpoints and custom domains. Endpoints are created within a CDN.
  • The CDN Rule builder, which creates CDN rules with conditions and actions that can be added to an endpoint

CDN Builder Keywords

KeywordPurpose
nameSets the name of the CDN instance.
skuSets the SKU of the CDN instance. Defaults to Standard Akamai.
add_endpointsAdds several endpoints to the CDN.

Endpoint Builder Keywords

KeywordPurpose
nameSets the name of the endpoint instance. If you do not set this, a name is generated based on the origin.
originSets the address of the origin and is used to auto-generate the endpoint name if none is supplied.
depends_onSets dependencies on this endpoint.
add_compressed_contentAdds a set of content types to compress.
query_string_caching_behaviourSpecifies the Query String Caching Behaviour.
enable_httpEnables HTTP delivery on the endpoint.
disable_httpDisables HTTP delivery on the endpoint.
enable_httpsEnables HTTPS delivery on the endpoint.
disable_httpsDisables HTTPS delivery on the endpoint.
custom_domainSets the custom domain name to use on the endpoint.
optimise_forOptimises delivery for a specific type of content.
add_ruleAdds a single rule to the endpoint delivery policy.
add_rulesAdds multiple rule to the endpoint delivery policy.

CDN Rule Builder Keywords

KeywordPurpose
nameSets the name of the rule.
orderSets the order of rule.
when_device_typeAdds device type condition.
when_http_versionAdds http version condition.
when_request_cookiesAdds request cookies condition.
when_post_argumentAdds post argument condition.
when_query_stringAdds query string condition.
when_remote_addressAdds remote address condition.
when_request_bodyAdds request body condition.
when_request_headerAdds request header condition.
when_request_methodAdds request method condition.
when_request_protocolAdds request protocol condition.
when_request_urlAdds request URL condition.
when_url_file_extensionAdds URL file extension condition.
when_url_file_nameAdds URL file name condition.
when_url_pathAdds URL path condition.
cache_expirationAdds cache expiration action.
cache_key_query_stringAdds cache key query string action.
modify_request_headerAdds modify request header action.
modify_response_headerAdds modify response header action.
url_rewriteAdds URL rewrite action.
url_redirectAdds URL redirect action.

Storage Accounts and Web Apps have special support for CDN endpoints. You can supply a storage account or web app builders directly as the origin.

Example

let isaacWebApp = webApp {
    name "isaacsuperweb"
    app_insights_off
}

let isaacStorage = storageAccount {
    name "isaacsuperstore"
}

let isaacRule = cdnRule {
    name "isaacsuperrule"
    order 1
    when_request_header "issac" Contains ["great"] ToLowercase
    modify_response_header Append "issac" "super"
}

let isaacCdn = cdn {
    name "isaacsupercdn"
    add_endpoints [
        endpoint {
            origin isaacStorage
            optimise_for Cdn.OptimizationType.LargeFileDownload
        }
        endpoint {
            origin isaacWebApp
            disable_http
        }
        endpoint {
            name "custom-endpoint-name"
            origin "mysite.com"
            add_compressed_content [ "text/plain"; "text/html"; "text/css" ]
            query_string_caching_behaviour Cdn.BypassCaching
            add_rule isaacRule
        }
    ]
}