Skip to content

Latest commit

 

History

History
149 lines (97 loc) · 5.61 KB

create-profile-endpoint-terraform.md

File metadata and controls

149 lines (97 loc) · 5.61 KB
ROBOTStitletitleSuffixdescriptionservicesms.servicems.topicms.datems.customauthorms.authorcontent_well_notificationai-usage
NOINDEX
Quickstart: Create an Azure CDN profile and endpoint using Terraform
Azure Content Delivery Network
In this article, you create an Azure CDN profile and endpoint using Terraform
cdn
azure-cdn
quickstart
03/31/2025
devx-track-terraform
TomArcherMsft
tarcher
AI-contribution
ai-assisted

Quickstart: Create an Azure CDN profile and endpoint using Terraform

[!INCLUDE Azure CDN from Microsoft (classic) retirement notice]

This article shows how to use Terraform to create an Azure CDN profile and endpoint using Terraform.

[!INCLUDE Terraform abstract]

In this article, you learn how to:

[!div class="checklist"]

Prerequisites

Implement the Terraform code

  1. Create a directory in which to test and run the sample Terraform code and make it the current directory.

  2. Create a file named main.tf and insert the following code:

    [!code-terraformmaster]

  3. Create a file named outputs.tf and insert the following code:

    [!code-terraformmaster]

  4. Create a file named providers.tf and insert the following code:

    [!code-terraformmaster]

  5. Create a file named variables.tf and insert the following code:

    [!code-terraformmaster]

Initialize Terraform

[!INCLUDE terraform-init.md]

Create a Terraform execution plan

[!INCLUDE terraform-plan.md]

Apply a Terraform execution plan

[!INCLUDE terraform-apply-plan.md]

Verify the results

  1. Get the Azure resource group name in which the Azure CDN profile and endpoint were created.

    resource_group_name=$(terraform output -raw resource_group_name)
  2. Get the CDN profile name.

    cdn_profile_name=$(terraform output -raw cdn_profile_name)
  3. Get the CDN endpoint name.

    cdn_endpoint_endpoint_name=$(terraform output -raw cdn_endpoint_endpoint_name)
  4. Run az cdn custom-domain show to show details of the custom domain you created in this article.

    az cdn endpoint show --resource-group $resource_group_name \ --profile-name $cdn_profile_name \ --name $cdn_endpoint_endpoint_name 
  1. Get the Azure resource group name in which the Azure CDN profile and endpoint were created.

    $resource_group_name=$(terraform output -raw resource_group_name)
  2. Get the CDN profile name.

    $cdn_profile_name=$(terraform output -raw cdn_profile_name)
  3. Get the CDN endpoint name.

    $cdn_endpoint_endpoint_name=$(terraform output -raw cdn_endpoint_endpoint_name)
  4. Run Get-AzCdnEndpoint to show details of the custom domain you created in this article.

    Get-AzCdnEndpoint -ResourceGroupName $resource_group_name ` -ProfileName $cdn_profile_name ` -Name $cdn_endpoint_endpoint_name

Clean up resources

[!INCLUDE terraform-plan-destroy.md]

Troubleshoot Terraform on Azure

Troubleshoot common problems when using Terraform on Azure

Next steps

[!div class="nextstepaction"] Tutorial: Use CDN to serve static content from a web app

close